Memra

Solving recurrences II: the master theorem

◈ 6 cards

The three cases around the watershed n^(log_b a), the regularity condition, the gap case, and an empirical demonstration that merge sort is Θ(n lg n).

The cookbook for divide-and-conquer recurrences

The master theorem solves any master recurrence

in one of three cases. The whole method turns on comparing the driving function to the watershed function . That watershed counts the leaves of the recursion tree: the tree has of them.

The three cases

Let .

  • Case 1 — leaves win. If for some (i.e. is polynomially smaller than ), then .
  • Case 2 — tie. If for some , then — the cost is shared across all levels, and one extra log factor is tacked on. The common subcase : gives .
  • Case 3 — root wins. If for some and the regularity condition holds for some and all large , then .

The in cases 1 and 3 demands polynomial separation: a mere logarithmic gap between and falls outside the theorem.

Worked classifications

  • (merge sort): , ⟶ case 2, .
  • : , so ; ⟶ case 1 (leaves dominate) ⟶ .
  • (binary-search shape): , , ⟶ case 2, .
  • : , , and regularity holds with ⟶ case 3 ⟶ .
  • : , ⟶ case 2 with . (Common slip: this is not .)

The gap case — when no case applies

: here and , pointing toward case 1 — but is not for any (it trails only by a log factor, not a polynomial one). Case 2 also fails (). The recurrence falls in the gap between cases 1 and 2 and needs another tool (Akra–Bazzi gives ).

Empirical check

You can't time wall-clock deterministically, but you can count the exact work merge sort does. On a reverse-sorted input each merge does moves per level over levels, so total moves exactly — and the ratio moves is a flat constant as grows. The exercise below shows that constant.

T(n) =Wf(n)casesolution2T(n/2) + Θ(n)nn2,k=0Θ(n lg n)9T(n/3) + nn1Θ(n²)T(2n/3) + 1112,k=0Θ(lg n)3T(n/4) + n lgnn^log₄3n lgn3Θ(n lg n)2T(n/2) + n lgnnn lgn2,k=1Θ(n lg²n)Row 1 is merge sort. Row 4 also needs the regularity check, which holds with c = 3/4.
The lesson’s own classifications in one place. The last row is the trap: matching W up to a single log factor is case 2 with k = 1, so a second log is added.
casef(n) vs Walso needsT(n)1 — leaves winf = O(W/nᵋ)Θ(W)2 — tief = Θ(W·lgᵏn)k ≥ 0Θ(W·lgᵏ⁺¹n)3 — root winsf = Ω(W·nᵋ)a·f(n/b) ≤ c·f(n)Θ(f(n))ε > 0 demands polynomial separation. If f trails or leads W by only a logarithmic factor no case applies— that is the gap, e.g. 2T(n/2) + n/lg n.
W = n^(log_b a) is the watershed — the leaf count of the recursion tree. Every case asks one question: is f smaller than, tied with, or larger than W, by a polynomial factor?
NORMAL ~/memra/learn/comp-372/master-theorem utf-8 LF