12.DivideAndConquer_outside

# 4 2 2 3 2 2 2 2 2 2 2 2 2 2 2 4 4 3 3 2 2 2 n bn bn n

• Notes
• 19

This preview shows pages 5–12. Sign up to view the full content.

4 ) 2 / ( 2 3 ) 2 / ( 2 2 ) 2 / ( 2 )) 2 / ( )) 2 / ( 2 ( 2 ) 2 / ( 2 ) ( 4 4 3 3 2 2 2 n bn bn n T log ) (

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

© 2004 Goodrich, Tamassia Divide-and-Conquer 6 The Recursion Tree Draw the recursion tree for the recurrence relation and look for a pattern: depth T’s size 0 1 n 1 2 n / 2 i 2 i n / 2 i 2 if ) 2 / ( 2 2 if ) ( n bn n T n b n T time bn bn bn Total time = bn + bn log n (last level plus all previous levels)
© 2004 Goodrich, Tamassia Divide-and-Conquer 7 Guess-and-Test Method In the guess-and-test method, we guess a closed form solution and then try to prove it is true by induction: Guess: T(n) < cn log n. Wrong: we cannot make this last line be less than cn log n n bn cn n cn n bn n cn n bn n n c n bn n T n T log log log ) 2 log (log log )) 2 / log( ) 2 / ( ( 2 log ) 2 / ( 2 ) ( 2 if log ) 2 / ( 2 2 if ) ( n n bn n T n b n T

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

© 2004 Goodrich, Tamassia Divide-and-Conquer 8 Guess-and-Test Method, (cont.) Recall the recurrence equation: Guess #2: T(n) < cn log 2 n. if c > b. So, T(n) is O(n log 2 n). In general, to use this method, you need to have a good guess and you need to be good at induction proofs. n cn n bn cn n cn n cn n bn n cn n bn n n c n bn n T n T 2 2 2 2 log log log 2 log log ) 2 log (log log )) 2 / ( log ) 2 / ( ( 2 log ) 2 / ( 2 ) ( 2 if log ) 2 / ( 2 2 if ) ( n n bn n T n b n T
© 2004 Goodrich, Tamassia Divide-and-Conquer 9 Master Method (Appendix) Many divide-and-conquer recurrence equations have the form: The Master Theorem: d n n f b n aT d n c n T if ) ( ) / ( if ) ( . 1 some for ) ( ) / ( provided )), ( ( is ) ( then ), ( is ) ( if 3. ) log ( is ) ( then ), log ( is ) ( if 2. ) ( is ) ( then ), ( is ) ( if 1. log 1 log log log log n f b n af n f n T n n f n n n T n n n f n n T n O n f a k a k a a a b b b b b

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

© 2004 Goodrich, Tamassia Divide-and-Conquer 10 Master Method, Example 1 The form: The Master Theorem: Example: d n n f b n aT d n c n T if ) ( ) / ( if ) ( . 1 some for ) ( ) / ( provided )), ( ( is ) ( then ), ( is ) ( if 3. ) log ( is ) ( then ), log ( is ) ( if 2. ) ( is ) ( then ), ( is ) ( if 1. log 1 log log log log n f b n af n f n T n n f n n n T n n n f n n T n O n f a k a k a a a b b b b b n n T n T ) 2 / ( 4 ) ( Solution: log b a=2, so case 1 says T(n) is O(n 2 ).

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

This is the end of the preview. Sign up to access the rest of the document.
• Fall '09
• Recurrence relation, Tamassia

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern