Linear Recurrences
Iteration & Expansion
Master the technique of unrolling recurrence relations step by step to discover closed-form solutions.
What Is a Recurrence Relation?
A recurrence relation defines each term of a sequence using previous terms. Instead of a direct formula, you get a recursive rule plus an initial condition.
Our goal: convert this recursive definition into a closed-form formula that computes \( T(n) \) directly for any \( n \).
Why Use Iteration?
Visualising the Unrolling Process
The General Form
A first-order linear recurrence has the form:
Expansion When \( a = 1 \)
If \( T(n) = T(n-1) + f(n) \), expanding gives:
Expansion When \( a \neq 1 \)
If \( T(n) = a \cdot T(n-1) + f(n) \), each substitution multiplies earlier \( f \)-terms by extra factors of \( a \):
Homogeneous vs. Non-Homogeneous
| Homogeneous | Non-Homogeneous | |
|---|---|---|
| Form | \( T(n) = a\,T(n-1) \) | \( T(n) = a\,T(n-1) + f(n) \) |
| \( f(n) \) | 0 (nothing added) | Non-zero driving term |
| Expansion result | \( a^n \cdot T(0) \) | \( a^n T(0) + \displaystyle\sum a^{n-k}f(k) \) |
| Difficulty | Straightforward | Requires evaluating the sum |
How to Apply Iteration
Example 1: Constant Additive
Example 2: Geometric Growth
Example 3: Variable Driving Term
Example 4: Scaling + Linear Term
The Expansion Blueprint
Common Mistakes
Question 1 of 5
Solve by iteration: \( T(n) = T(n-1) + 4 \), \( T(0) = 5 \). What is \( T(n) \)?
Question 2 of 5
Solve: \( T(n) = 2\,T(n-1) \), \( T(0) = 3 \). What is \( T(n) \)?
Question 3 of 5
After expanding \( T(n) = 3\,T(n-1) + 5 \) with \( T(0) = 0 \), the sum you need to evaluate is:
Question 4 of 5
Solve: \( T(n) = T(n-1) + 2n \), \( T(0) = 1 \). What is \( T(n) \)?
Question 5 of 5
What value does \( T(5) \) equal for the recurrence \( T(n) = 2\,T(n-1) + 1 \), \( T(0) = 0 \)?