3. Extended Master Method
Here, a >= 1, b > 1, k >= 0 and p is a real number.
To solve recurrence relations using Master’s
theorem, we compare a with bk.
Then, we follow the following cases-
3
Mr. Jeetesh Srivastava (DAA(KCS503))
4. Extended Master Method (cont)
Case-01:
If a > bk, then T(n) = θ (nlog
b
a)
Case-02:
If a = bk and
If p < -1, then T(n) = θ (nlog
b
a)
If p = -1, then T(n) = θ (nlog
b
a.log2n)
If p > -1, then T(n) = θ (nlog
b
a.logp+1n)
Case-03:
If a < bk and
If p < 0, then T(n) = O (nk)
If p >= 0, then T(n) = θ (nklogpn)
4
Mr. Jeetesh Srivastava (DAA(KCS503))
5. Example-1
Ex: Solve the following recurrence relation using
Master’s theorem- T(n) = 2T(n/2) + nlogn
Solution: We compare the given recurrence relation
with T(n) = aT(n/b) + θ (nklogpn).
Then, we have- a = 2, b = 2, k = 1, p = 1
Now, a = 2 and bk = 21 = 2.
Clearly, a = bk.
So From Case 2, Since p = 1, so we have-
T(n) = θ (nlog
b
a.logp+1n)
T(n) = θ (nlog
2
2.log1+1n)
5
Mr. Jeetesh Srivastava (DAA(KCS503))
7. Example-2
Ex: Solve the following recurrence relation using
Master’s theorem- T(n) = 2T(n/4) + n0.51
Solution: We compare the given recurrence relation
with T(n) = aT(n/b) + θ (nklogpn).
Then, we have- a = 2, b = 4, k = 0.51, p = 0
Now, a = 2 and bk = 40.51 = 2.0279.
Clearly, a < bk.
So From Case 3, Since p = 0, so we have-
T(n) = θ (nklogpn)
T(n) = θ (n0.51log0n)
7
Mr. Jeetesh Srivastava (DAA(KCS503))
9. Example-3
Ex: Solve the following recurrence relation using
Master’s theorem- T(n) = √2T(n/2) + logn
Solution: We compare the given recurrence relation
with T(n) = aT(n/b) + θ (nklogpn).
Then, we have- a = √2, b = 2, k = 0, p = 1
Now, a = √2 = 1.414 and bk = 20 = 1.
Clearly, a > bk.
So From Case 1,
T(n) = θ (nlog
b
a) = θ (nlog
2
√2)
T(n) = θ (n1/2)
9
Mr. Jeetesh Srivastava (DAA(KCS503))