MIT Video Lecture on Asymptotic Notation | Recurrences | Substitution, Master Method Next – Analysis of Algorithm | Set 5 (Amortized Analysis Introduction) Practice Problems and Solutions on Master Theorem. If f(n) = Θ(n cLog kn) for some constant k >= 0 and c = Log ba, then T(n) = Θ(n cLog k+1n) For example, the recurrence T(n) = 2T(n/2) + n/Logn cannot be solved using master method.Ģ) Case 2 can be extended for f(n) = Θ(n cLog kn) The given three cases have some gaps between them. So the solution is Θ(Logn)ġ) It is not necessary that a recurrence of the form T(n) = aT(n/b) + f(n) can be solved using Master Theorem. It also falls in case 2 as c is 0 and Log ba is also 0. So the solution is Θ(n Logn)īinary Search: T(n) = T(n/2) + Θ(1). It falls in case 2 as c is 1 and Log ba] is also 1. If work done at the root is asymptotically more, then our result becomes work done at the root (Case 3).Įxamples of some standard algorithms whose time complexity can be evaluated using the Master Method If work done at leaves and root is asymptotically the same, then our result becomes height multiplied by work done at any level (Case 2). If the work done at leaves is polynomially more, then leaves are the dominant part, and our result becomes the work done at leaves (Case 1). In the recurrence tree method, we calculate the total work done. And the height of the recurrence tree is Log bn
If we draw the recurrence tree of T(n) = aT(n/b) + f(n), we can see that the work done at the root is f(n), and work done at all leaves is Θ(n c) where c is Log ba. The master method is mainly derived from the recurrence tree method. If f(n) = O(n c) where c Log ba then T(n) = Θ(f(n)) We guess the solution as T(n) = O(nLogn).