Recurrence
Relations
Learn how to translate word problems into recursive equations that express each term using previous terms.
What Is a Recurrence Relation?
A recurrence relation is an equation that defines a sequence where each term is expressed as a function of one or more previous terms. Instead of a closed-form formula, we describe how to build the next value from what we already know.
Two Key Ingredients
How a Sequence Builds Itself
Why Recurrences Matter
Many problems in computer science, biology, finance, and combinatorics are naturally recursive. Before we can solve them, we need to formulate the recurrence: translate the story into math.
The Formulation Framework
Linear vs Non-Linear Recurrences
| Linear | Non-Linear | |
|---|---|---|
| Form | \( a(n) = c_1 a(n-1) + c_2 a(n-2) + f(n) \) | \( a(n) = a(n-1) \cdot a(n-2) \) |
| Terms appear | To the first power only | Multiplied, squared, etc. |
| Solvability | Standard methods exist | Often requires special techniques |
| Example | \( a(n) = 2a(n-1) + 3 \) | \( a(n) = a(n-1)^2 \) |
Homogeneous vs Non-Homogeneous
Example: \( a(n) = 3a(n-1) - 2a(n-2) \)
Example: \( a(n) = 2a(n-1) + n \)
Step-by-Step Approach
Example 1: Tower of Hanoi
Problem: How many moves \( H(n) \) are needed to transfer \( n \) disks from one peg to another, moving one disk at a time, never placing a larger disk on a smaller one?
Hanoi Recurrence
Example 2: Bit Strings
Problem: How many bit strings of length \( n \) have no two consecutive 0s?
Bit Strings Recurrence
Example 3: Savings Account
Problem: You deposit $1000 into an account earning 5% annual interest. Each year you also deposit an additional $200. Find a recurrence for the balance \( B(n) \) after \( n \) years.
Common Mistakes
Recurrence Cheat Sheet
| Problem Type | Recurrence Pattern | Order |
|---|---|---|
| Each step doubles | \( a(n) = 2a(n-1) \) | 1st |
| Split into two sub-cases | \( a(n) = a(n-1) + a(n-2) \) | 2nd |
| Add constant each step | \( a(n) = a(n-1) + c \) | 1st (NH) |
| Multiply + add | \( a(n) = r \cdot a(n-1) + f(n) \) | 1st (NH) |
| Divide and conquer | \( T(n) = aT(n/b) + f(n) \) | Special |
Question 1 of 5
A population of bacteria triples every hour. If we start with 100 bacteria, what is the recurrence for \( P(n) \), the population after \( n \) hours?
Question 2 of 5
You climb a staircase of \( n \) steps, taking either 1 or 2 steps at a time. If \( S(n) \) is the number of ways to climb, what is the recurrence?
Question 3 of 5
The Tower of Hanoi recurrence is \( H(n) = 2H(n-1) + 1 \) with \( H(1) = 1 \). What is \( H(4) \)?
Question 4 of 5
Which recurrence is non-homogeneous?
Question 5 of 5
A cell divides into 2 cells every hour, but 1 cell dies each hour. Starting with 5 cells, what recurrence models \( C(n) \), the cell count after \( n \) hours?