


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



10/3/2002 CSE 202 - Recurrences
2
2
3 CSE 202 - Recurrences
c n/b^2 c n/b^2 c n/b^2 c n/b^2
... a^2 depth-2 nodes
logbn
... ...
... (^) c c (^) c
... ...
c (^) c c c (^) c c
T(n) < c ( 1 + a(n/b) + a^2 (n/b 2 ) + ... + a logbn (n/ b logbn ) )
< cn ( 1 + a/b + (a/b) 2
How does your tree grow?
What’s T(n) = cn ( 1 + a/b + (a/b)^2 + ... + (a/b)logbn^ )?
The largest term of a geometric series “dominates”.
Thus, T(n) e Q(n).
So T(n) e Q(n(a/b) logbn^ ) = Q(n(a logbn /b logbn ) ) = Q(n(a logbn /n) ) = Q(a logbn ) = Q(n logba ).
7 CSE 202 - Recurrences
Previous slide is “Master Method”
Slight differences:
Book’s condition on case 1, “f(n) is O(n logba-e )”, is
Case 2 – remember a logbn^ = n logba.
Book has (unnecessary) extra condition in case 3
Other recurrences
Master Method doesn’t always apply:
What if, in MergeSort, we divided 75% - 25%?
Or we divided into 1000 and n-1000 sized pieces?
Or consider: