12.DivideAndConquer_outside

Log is then log is if 2 is then is if 1 log 1 log log

Info icon This preview shows pages 15–19. Sign up to view the full content.

View Full Document Right Arrow Icon
) 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 1 ) 2 / ( ) ( n T n T Solution: log b a=0, so case 2 says T(n) is O(log n). (binary search)
Image of page 15

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

View Full Document Right Arrow Icon
© 2004 Goodrich, Tamassia Divide-and-Conquer 16 Master Method, Example 7 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 log ) 2 / ( 2 ) ( Solution: log b a=1, so case 1 says T(n) is O(n). (heap construction)
Image of page 16
© 2004 Goodrich, Tamassia Divide-and-Conquer 17 Iterative “Proof” of the Master Theorem Using iterative substitution, let us see if we can find a pattern: We then distinguish the three cases as The first term is dominant Each part of the summation is equally dominant The summation is a geometric series 1 ) (log 0 log 1 ) (log 0 log 2 2 3 3 2 2 2 ) / ( ) 1 ( ) / ( ) 1 ( . . . ) ( ) / ( ) / ( ) / ( ) ( ) / ( ) / ( )) / ( )) / ( ( ) ( ) / ( ) ( n i i i a n i i i n b b b b b n f a T n b n f a T a n f b n af b n f a b n T a n f b n af b n T a bn b n f b n aT a n f b n aT n T
Image of page 17

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

View Full Document Right Arrow Icon
© 2004 Goodrich, Tamassia Divide-and-Conquer 18 Integer Multiplication Algorithm: Multiply two n-bit integers I and J. Divide step: Split I and J into high-order and low-order bits We can then define I*J by multiplying the parts and adding: So, T(n) = 4T(n/2) + n, which implies T(n) is O(n 2 ). But that is no better than the algorithm we learned in grade school. l n h l n h J J J I I I 2 / 2 / 2 2 l l n h l n l h n h h l n h l n h J I J I J I J I J J I I J I 2 / 2 / 2 / 2 / 2 2 2 ) 2 ( * ) 2 ( *
Image of page 18
© 2004 Goodrich, Tamassia Divide-and-Conquer 19 An Improved Integer Multiplication Algorithm Algorithm: Multiply two n-bit integers I and J. Divide step: Split I and J into high-order and low-order bits Observe that there is a different way to multiply parts: So, T(n) = 3T(n/2) + n, which implies T(n) is O(n log 2 3 ), by the Master Theorem.
Image of page 19
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern