Master Method

Document last modified: 
  • T(n) = a * T(n/b) + f(n)                  where n/b replaces either ⌊n/b⌋ or ⌈n/b⌉
  • a ≥ 1 the number of subproblems
  • b > 1
  • f(n) = D(n)+C(n) is a function describing the cost of dividing and combining

T(n) can be asymptotically bounded for 3 cases as follows:

  1. f(n) < nlogba                Intuitively: cost is dominated by leaves.

    If f(n) = O(nlogba - ε ) for some constant ε > 0 then T(n) ∈ Θ (nlogba)

  2. f(n) = nlogba

    If f(n) = Θ(nlogba ) then T(n) ∈ Θ(nlogba * lg n)

  3. f(n) > nlogba           Intuitively: cost is dominated by root.

    If f(n) = Ω(nlogba +ε ) for some constant ε > 0 and

    af(n/b) ≤ cf(n) for some constant c < 1 and all sufficiently large n

    then T(n) ∈ Θ(f(n))

    i.e. f(n) is polynomially greater than nlogba

Use the Master Method to asymptotically bound T(n)

  1. 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

    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)

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)

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)