0% found this document useful (0 votes)
12 views2 pages

Masters Theorem

master theorm

Uploaded by

v28424976
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Masters Theorem

master theorm

Uploaded by

v28424976
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Master’s Theorem

(Reading Material)

Master’s Method or Master’s Theorem is a direct way to get the solution for a
recursive code’s Time Complexity. Master’s theorem works only for the following
type of recurrences or for recurrences that can be transformed into the following
type :

T(n) = aT(n/b) + f(n) where a >= 1 and b > 1

There are the following three cases:


❖ If f(n) = O(nc) where c < Logba then T(n) = Θ(n * Logba)
❖ If f(n) = Θ(nc) where c = Logba then T(n) = Θ(nc * Log n)
❖ If f(n) = Ω(nc) where c > Logba then T(n) = Θ(f(n))

How does this work?

This is how a recursive tree for such problems will be like :

In the recurrence tree method, we calculate the total work done.


Case 1 : 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 2 : If work done at leaves and root is asymptotically the same, then our result
becomes height multiplied by work done at any level
Case 3 : If work done at the root is asymptotically more, then our result becomes
work done at the root

Examples of some standard algorithms whose time complexity can be evaluated


using the Master’s Theorem :

❖ Merge Sort: T(n) = 2T(n/2) + Θ(n). It falls in case 2 as c is 1 and


Logba is also 1. So the solution is Θ(n * Logn)

❖ Binary Search: T(n) = T(n/2) + Θ(1). It also falls in case 2 as c is 0


and Logba is also 0. So the solution is Θ(Logn)

You might also like