lecture13 - Introduction to Algorithms...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 13 Prof. Erik Demaine
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction to Algorithms Day 23 L12.2 © 2001 by Erik D. Demaine Fixed-universe successor problem Goal: Maintain a dynamic subset S of size n of the universe U = {0, 1, …, u –1} of size u subject to these operations: I NSERT ( x U \ S ) : Add x to S . D ELETE ( x S ) : Remove x from S . S UCCESSOR ( x U ) : Find the next element in S larger than any element x of the universe U . P REDECESSOR ( x U ) : Find the previous element in S smaller than x .
Background image of page 2
Introduction to Algorithms Day 23 L12.3 © 2001 by Erik D. Demaine Solutions to fixed-universe successor problem Goal: Maintain a dynamic subset S of size n of the universe U = {0, 1, …, u –1} of size u subject to I NSERT, D ELETE, S UCCESSOR, P REDECESSOR . Balanced search trees can implement operations in O(lg n ) time, without fixed-universe assumption. In 1975, Peter van Emde Boas solved this problem in O(lg lg u ) time per operation. If u is only polynomial in n , that is, u = O( n c ) , then O(lg lg n ) time per operation-- exponential speedup!
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction to Algorithms Day 23 L12.4 © 2001 by Erik D. Demaine O(lg lg u ) ?! Where could a bound of O(lg lg u ) arise? • Binary search over O(lg u ) things T ( u ) = T ( ) + O(1) T’ (lg u ) = T’ ( (lg u )/2 ) + O(1) = O(lg lg u ) u
Background image of page 4
Introduction to Algorithms Day 23 L12.5 © 2001 by Erik D. Demaine (1) Starting point: Bit vector Bit vector v stores, for each x U , 1 if x S 0 if x S v x = Insert/Delete run in O(1) time. Successor/Predecessor run in O( u ) worst-case time. Example : u = 16 ; n = 4 ; S = {1, 9, 10, 15} . 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Introduction to Algorithms Day 23 L12.6 © 2001 by Erik D. Demaine (2) Split universe into widgets Example : u = 16 , 4 = u . 0 1 0 0 0123 0 0 0 0 4567 1 0 1 0 8 9 10 11 0 0 0 1 12 13 14 15 W 0 W 1 W 2 W 3 Carve universe of size u into widgets u W 0 , W 1 , …, W 1 u each of size u .
Background image of page 6
Introduction to Algorithms Day 23 L12.7 © 2001 by Erik D. Demaine (2) Split universe into widgets W 0 represents 0, 1, …, 1 u U ; W 1 represents 1 2 u U ; u , 1 + u , …, W i represents 1 ) 1
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/09/2009 for the course CSE 6.046J/18. taught by Professor Piotrindykandcharlese.leiserson during the Fall '04 term at MIT.

Page1 / 23

lecture13 - Introduction to Algorithms...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online