Master Method |
Document last modified: |
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) + Θ(n2)
Case 1: If f(n) = O(nlogba - ε ) for some constant ε > 0 then T(n) ∈ Θ(nlogba)
Determine: a, b, f(n) and logba
a = 5
b = 2
f(n) = Θ(n2)
logb a = log2 5 ≈ 2.32
Is f(n) ∈ O(nlg 5 - ε) for ε > 0 ?
Yes. f(n) = Θ(n2) ∈ O(nlg 5 - ε) = O(n2.32 - ε) for ε ≈ 0.32
T(n) ∈ Θ(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) = Θ(nlogba ) then T(n) ∈ Θ(nlogba lg n)
f(n) = n ∈ Θ(nlog22) = Θ(n1)
T(n) ∈ Θ(nlog22 lg n) = Θ(n lg n)
3. T(n) = 5T(n/2) + Θ(n3)
Determine: a, b, f(n) and logb(a)
a = 5
b = 2
f(n) = Θ(n3)
logb a = log2 5 ≈ 2.32
Case 3: If f(n) = Ω(nlogba+ε ) for some constant ε > 0
f(n) = Θ(n3) ∈ Ω(nlog25+ε ) = Ω(n2.32+ε ) for ε ≈ 0.68
OR
f(n) = Θ(n3) ∈ Ω(nlog25+ε ) = Ω(nlog25+3 ) (for ε=3) = Ω(nlog28 ) = Ω(nlog28 ) = Ω(n3 )
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) ∈ Θ(n3)