Improvised Master’s Theorem
Presented By:
Laiba Younas
INTRODUCTION:
• Master’s Theorem is a Popular method for solving the recurrence
relations.
• It is used to compute the complexity of a given divide and conquer
problem in asymptotic time.
• In divide and conquer problem we have three steps:
Divide a large problem into smaller subproblems;
Recursively solve each subproblem, then
Combine solutions of the subproblems to solve the original
problem.
2
The form of the recurrence relation of the master’s theorem is:
T (n) = aT (n/b) + f(n)
where a ≥ 1 and b > 1 are constants and f(n) is an asymptotically
positive function.
In above equation:
 n = problem size
 a = number of sub problems
 n/b = size of each sub problem
 f (n) = cost of the work done outside the recursive calls
3
Master’s Theorem cases:
• If T (n) = aT (n/b) + O(nd) where d>=0, then
Example:
T(n) = 4T(n/2) + n
a = 4, b=2, f(n) = n1, so d = 1
logb a ----> log2 4 = 2
d < logba
1<2
so,
n = O (nlog2 4)
= O (n2)
4
PROBLEM STATEMENT:
The earlier used theorem has some limitations. Some equations could not be solved
using the original master’s theorem.
Here are some examples:
T(n)= 0.5T(n/2) + n
In this equation a<1. The number of subproblems is 0.5 whereas there needs to be
at least 1 subproblem.
T(n)= 2T(n/2) + n/log n
Master theorem apply only for polynomial, the difference here is not polynomial but
logarithmic.
T(n)= 2n T(n/2) + nn
Now in this case we can see that ‘a’ is not a constant therefore master’s theorem
won’t be applied.
So, to resolve such problems the master’s theorem has been revised.
5
SOLUTION:
T(n)=aT(n/b) + θ (nd logp n)
(a>=1, b>=1, d>=0 and p is a real number)
• Case 1:
If d < logb a, then T(n) = θ (nlogb a)
• Case 2:
If d = logb a
 If p > -1 then, T(n) = θ (nd logp+1 n)
 If p = -1 then, T(n) = θ (nd log log n)
 If p < -1 then, T(n) = θ (nd)
• Case 3:
If d > logb a
 If p >= 0 then, T(n) = θ (nd logp n)
 If p < 0 then, T(n) = O (nd)
6
The proposed solution is used to solve the problem like:
Example:
T(n) = 64T (n/8) + n2 log n
Now we will compare the above equation with proposed format we got.
a = 64, b = 8, d = 2, p = 1
Let’s compute logba: log8 64 = 2
2 = 2
logba = d
So, it satisfies the 2nd case i.e T(n) = θ (nd logp+1 n)
Therefore, the solution is θ (n2 log2 n)
7
Here’s another example:
T(n)= 2T(n/2) + n/log n
Now we will compare the above equation with proposed format we got.
a = 2, b = 2, d = 1, p = -1;
Let’s compute logba: log2 2 = 1
1 = 1
logba = d
So, it satisfies the 2nd case i.e T(n) = θ (nd loglog n)
Therefore the solution is θ (n loglog n)
8
CONCLUSION:
• Those equations that could not be solved using the original master’s
method but after the relaxation of the constraints they can be solved
using the new approach.
• It also helps us to reduce the time complexity in comparison if the
relation is solved using iterative and substitution method.
• The proposed method is able to relax some of the constraints of the
original method.
9
THANK YOU!
10

Improvised Master's Theorem

  • 1.
  • 2.
    INTRODUCTION: • Master’s Theoremis a Popular method for solving the recurrence relations. • It is used to compute the complexity of a given divide and conquer problem in asymptotic time. • In divide and conquer problem we have three steps: Divide a large problem into smaller subproblems; Recursively solve each subproblem, then Combine solutions of the subproblems to solve the original problem. 2
  • 3.
    The form ofthe recurrence relation of the master’s theorem is: T (n) = aT (n/b) + f(n) where a ≥ 1 and b > 1 are constants and f(n) is an asymptotically positive function. In above equation:  n = problem size  a = number of sub problems  n/b = size of each sub problem  f (n) = cost of the work done outside the recursive calls 3
  • 4.
    Master’s Theorem cases: •If T (n) = aT (n/b) + O(nd) where d>=0, then Example: T(n) = 4T(n/2) + n a = 4, b=2, f(n) = n1, so d = 1 logb a ----> log2 4 = 2 d < logba 1<2 so, n = O (nlog2 4) = O (n2) 4
  • 5.
    PROBLEM STATEMENT: The earlierused theorem has some limitations. Some equations could not be solved using the original master’s theorem. Here are some examples: T(n)= 0.5T(n/2) + n In this equation a<1. The number of subproblems is 0.5 whereas there needs to be at least 1 subproblem. T(n)= 2T(n/2) + n/log n Master theorem apply only for polynomial, the difference here is not polynomial but logarithmic. T(n)= 2n T(n/2) + nn Now in this case we can see that ‘a’ is not a constant therefore master’s theorem won’t be applied. So, to resolve such problems the master’s theorem has been revised. 5
  • 6.
    SOLUTION: T(n)=aT(n/b) + θ(nd logp n) (a>=1, b>=1, d>=0 and p is a real number) • Case 1: If d < logb a, then T(n) = θ (nlogb a) • Case 2: If d = logb a  If p > -1 then, T(n) = θ (nd logp+1 n)  If p = -1 then, T(n) = θ (nd log log n)  If p < -1 then, T(n) = θ (nd) • Case 3: If d > logb a  If p >= 0 then, T(n) = θ (nd logp n)  If p < 0 then, T(n) = O (nd) 6
  • 7.
    The proposed solutionis used to solve the problem like: Example: T(n) = 64T (n/8) + n2 log n Now we will compare the above equation with proposed format we got. a = 64, b = 8, d = 2, p = 1 Let’s compute logba: log8 64 = 2 2 = 2 logba = d So, it satisfies the 2nd case i.e T(n) = θ (nd logp+1 n) Therefore, the solution is θ (n2 log2 n) 7
  • 8.
    Here’s another example: T(n)=2T(n/2) + n/log n Now we will compare the above equation with proposed format we got. a = 2, b = 2, d = 1, p = -1; Let’s compute logba: log2 2 = 1 1 = 1 logba = d So, it satisfies the 2nd case i.e T(n) = θ (nd loglog n) Therefore the solution is θ (n loglog n) 8
  • 9.
    CONCLUSION: • Those equationsthat could not be solved using the original master’s method but after the relaxation of the constraints they can be solved using the new approach. • It also helps us to reduce the time complexity in comparison if the relation is solved using iterative and substitution method. • The proposed method is able to relax some of the constraints of the original method. 9
  • 10.