Recurrence Relations

Difficulty
Importance

The problem

Recursive algorithms and recursively-defined data structures need a way to predict their total cost or size from the cost of their sub-problems. Recurrence relations are the equations that describe this self-reference, and solving them yields the closed-form growth rate.

Why now

Proof techniques supplies induction, the tool recurrences are solved and verified with; asymptotic growth supplies the vocabulary to classify the answer once solved. Recurrence relations are the formal object that sits between them — what you get when a recursive process is described mathematically.

Mental model

A recurrence relation is a function defined in terms of smaller inputs of itself, plus a base case — the mathematical shadow of a recursive function. Solving one, by substitution, recursion trees, or the master theorem, answers 'how much total work does this recursive algorithm do' before a single line of it runs.

Requires

Unlocks

Used in

Projects

  • Derive and solve the recurrence for merge sort by hand using a recursion tree, then confirm it matches O(n log n)
  • Write a recursive Fibonacci function, derive its (exponential) recurrence, then compare to the memoized version's recurrence

Examples

  • Binary search: T(n) = T(n/2) + O(1) solves to O(log n)
  • Naive recursive Fibonacci: T(n) = T(n-1) + T(n-2) + O(1) solves to O(2ⁿ) — which is exactly why memoization matters

Resources

Mastery checklist