Binary search
: one half and constant local work.
Algorithms · Complexity analysis
Recurrences translate the structure of a recursive algorithm into an equation. The Master Theorem quickly solves many divide-and-conquer recurrences, provided that all of its hypotheses are actually satisfied.
A recursive algorithm solves an instance using one or more smaller instances. Its running time is therefore the cost of the recursive calls plus the work performed outside them.
: one half and constant local work.
: two halves and linear merging.
: the problem shrinks by one.
The number of recursive calls produced by each instance. It must be at least 1.
Each subproblem has size ; the theorem requires .
Splitting, combining and every operation performed outside the recursive calls.
The leaf cost of the recursion tree is governed by
This is why the Master Theorem compares with .
Repeatedly expand the recurrence down to the base case, then identify and sum the resulting series.
Find the cost of each level, the number of levels and the leaf cost. This is especially useful for forming a hypothesis.
Guess an asymptotic bound and prove it by induction, choosing constants and the base case carefully.
Classify balanced recurrences of the form .
For :
The Master Theorem does not apply because the size changes from to , not to .
Let
Compare with . In cases 1 and 3, the gap must be polynomial.
| Case | Comparison | Result | Intuition |
|---|---|---|---|
| 1 | , some | Leaves dominate. | |
| 2 | , | All levels contribute. | |
| 3 | , some | The root dominates. |
| Recurrence | Critical term | Case | Solution |
|---|---|---|---|
| 2 | |||
| 2 | |||
| 1 | |||
| 1 | |||
| 3 |
Solve .
The critical term is , which polynomially dominates . Case 1 gives .
Solve .
Case 2 with gives .
Solve .
The critical term is ; regularity holds because . Case 3 gives .
Can the theorem solve ?
No. The shrinkage is subtractive. Expansion takes about constant-cost steps, so the result is .
Checklist: identify the form, compute , compare it with , and verify every hypothesis before selecting a case.