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

Master Theorem

The document discusses the Master's theorem for analyzing the time complexity of divide-and-conquer recursive algorithms. It provides examples of applying the theorem to problems with the recurrence relation T(n) = aT(n/b) + Y. Specifically, it shows determining the complexity class by calculating logba, comparing Y to N^x, and concluding whether the complexity is Y, N^x, or N^x(logn). Examples analyze problems with complexities of n^2, √n log n, and N^1.58.

Uploaded by

akshat sinha
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)
248 views2 pages

Master Theorem

The document discusses the Master's theorem for analyzing the time complexity of divide-and-conquer recursive algorithms. It provides examples of applying the theorem to problems with the recurrence relation T(n) = aT(n/b) + Y. Specifically, it shows determining the complexity class by calculating logba, comparing Y to N^x, and concluding whether the complexity is Y, N^x, or N^x(logn). Examples analyze problems with complexities of n^2, √n log n, and N^1.58.

Uploaded by

akshat sinha
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

T(n) = aT(n/b) +Y

Where Y is the complexity required per unit work (for smallest unit) and n/b is n ÷b and the equation is
valid for master theorem

To find complexity:-

1. Find logba
2. Let x= logba
3. Find nx
4. Compare Y and nx
5. If Y > nx then complexity is Y
6. If Y < nx then complexity is nx
7. If they are equal then answer will be nx (logn)

Note:- let Y is 5log n then here we treat Y as logn. Similarly if it is 5n^2 then we treat it as n^2

Q1 T(n) = T(n/2)+ (1/2)n2+ n

Which is equivalent to

T(n) = T(n/2)+ n2

As Y is the greatest upper bound of the whole (1/2)n2+ n

1 a = 1; b = 2; y = n2
2 Finding x of point 2.

X = logba
X = log21 =0

3 finding Nx = N0 =1

4 Y = n2 >1

5 so answer is n2
Q2. : T(n) = 2T(n/4) + √n + 42

Which is equivalent to

T(n) = 2T(n/4) + √n

1 a = 2; b = 4; Y= √n

2 Finding x of point 2.

X = logba
X = log42 =½

3 finding Nx = N½ =√n

4 Y =√n = Nx

5 so answer is √n xlogn or √n(logn)

Q3 Case 3: T(n) = 3T(n/2) + (3/4)n + 1

Which is equivalent to
Case 3: T(n) = 3T(n/2) + n
Now
1 a = 3; b = 2; Y= √n

2 Finding x of point 2.

X = logba
X = log23= 1.58

3 finding Nx = N 1. 58

4 Y =n < N 1. 58

5 so answer is N 1. 58

You might also like