Master Method |
T(n) can be asymptotically bounded for 3 cases as follows:
|
Use the Master Method to asymptotically bound T(n)
T(n) = 5T(n/2) + Q(n2)
Case 1: If f(n) = O(nlogba - e ) for some constant e > 0 then T(n) Î Q(nlogba)
Determine: a, b, f(n) and logba
a = 5
b = 2
f(n) = Q(n2)
logb a = log2 5 ≈ 2.32
Is f(n) Î O(nlg 5 - e) for e > 0 ?
Yes. f(n) = Q(n2) Î O(nlg 5 - e) = O(n2.32 - e) for e ≈ 0.32
T(n) Î Q(nlog25)
2. T(n) = 2T(n/2) + n
Determine: a, b, f(n) and logb(a)
a = 2
b = 2
f(n) = n
logb a = log2 2 = lg 2 = 1
Case 2: If f(n) = Q(nlogba ) then T(n) Î Q(nlogba lg n)
f(n) = n Î Q(nlog22) = Q(n1)
T(n) Î Q(nlog22 lg n) = Q(n lg n)
3. T(n) = 5T(n/2) + Q(n3)
Determine: a, b, f(n) and logb(a)
a = 5
b = 2
f(n) = Q(n3)
logb a = log2 5 ≈ 2.32
Case 3: If f(n) = W(nlogba+e ) for some constant e > 0
f(n) = Q(n3) Î W(nlog25+e ) = W(n2.32+e ) for e ≈ 0.68
and af(n/b) ≤ cf(n) for some constant c < 1 and all sufficiently large n
5(n/2)3 ≤ cn3
5n3/8 ≤ cn3
c = 5/8 < 1
then T(n) Î Q(n3)