Professional Documents
Culture Documents
Master Theorem
Master Theorem
Master Theorem
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
Which is equivalent to
T(n) = T(n/2)+ n2
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
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