Master Method

powered by FreeFind

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 - e ) for some constant e > 0 then T(n) Î Q (nlogba)

  2. f(n) = nlogba

    If f(n) = Q(nlogba ) then T(n) Î Q(nlogba * lg n)

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

    If f(n) = W(nlogba +e ) for some constant e > 0 and

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

    then T(n) Î Q(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) + 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

    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)

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)

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)