Lecture3

# Lecture3 - Lecture 3 Recurrences Algorithm calls itself...

This preview shows pages 1–3. Sign up to view the full content.

1 36 Recurrences Algorithm “calls itself” - recursive . First, solve for » Claim: » Proof by induction (on k): 11 () 1 2 n Tn n To t h e r w i s e      2 k n () l g 1 n  1 1 (1) 1 (2 ) (2 ) 1 lg(2 ) 1 1 2 lg(2 ) 1 QED kk k k T TT k Lecture 3, Sept 28, 2010 37 What if n not a power of 2 ? Easy to prove by induction that Now we can say: Observe that we did not prove Theta , only big-Oh ! Technically, we should be careful about floor/ceiling, but usually we can safely concentrate on n=power of 2 . More details in CLRS. (See web site for chapter numbers.) ( 1 ) Tn Tn  lg ( 2 ) l g 1 ( l o g) n Tn T n n 

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

View Full Document
2 38 Guessing the solution Instead of adding n numbers sequentially, lets divide into 2 parts, compute sum of each part recursively, and add the results: ( ) /2 1 Tn Tn Tn         Note that we omit the n=1 case for simplicity Guess: ( ) for some constant Then: ( ) 1 1 1 Tn cn c cn cn      Are we done ?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

Lecture3 - Lecture 3 Recurrences Algorithm calls itself...

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

View Full Document
Ask a homework question - tutors are online