01 / 20
n

Recurrence
Relations

Learn how to translate word problems into recursive equations that express each term using previous terms.

Discrete Math

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

Recursive Rule
An equation expressing \( a(n) \) in terms of earlier values like \( a(n-1) \), \( a(n-2) \), etc.
Initial Conditions
Specific starting values (e.g., \( a(0) = 1 \)) that anchor the sequence so we can compute every term.

How a Sequence Builds Itself

a(0) = 1 a(1) = 1 a(2) = 2 a(3) = 3 a(4) = 5 a(n) = a(n-1) + a(n-2) initial initial

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.

CS
Analyzing recursive algorithm run-times like merge sort: \( T(n) = 2T(n/2) + n \)
Finance
Compound interest: \( A(n) = (1+r) \cdot A(n-1) \)
Counting
Tiling a \( 2 \times n \) board with dominoes: \( T(n) = T(n-1) + T(n-2) \)

The Formulation Framework

1. Define a(n) precisely 2. Find how n relates to n-1 3. Write the equation 4. State initial conditions

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

Homogeneous
Only depends on previous \( a \)-terms, no extra function.
Example: \( a(n) = 3a(n-1) - 2a(n-2) \)
Non-Homogeneous
Has an added function \( f(n) \) beyond the \( a \)-terms.
Example: \( a(n) = 2a(n-1) + n \)

Step-by-Step Approach

1
Define \( a(n) \): State clearly what \( a(n) \) counts or measures at stage \( n \).
2
Consider stage \( n \): Think about the last action, decision, or change that brings you from stage \( n-1 \) to stage \( n \).
3
Express \( a(n) \) recursively: Write \( a(n) \) in terms of \( a(n-1) \), \( a(n-2) \), etc., adding any extra terms.
4
State initial conditions: Identify the smallest cases you can solve directly (often \( a(0) \) or \( a(1) \)).
5
Verify: Compute a few terms by hand to confirm the recurrence matches the problem.

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?

Source Auxiliary Target move n-1, then 1, then n-1

Hanoi Recurrence

1
Define: Let \( H(n) \) = minimum number of moves to transfer \( n \) disks.
2
Last action: Move top \( n-1 \) disks to auxiliary (\( H(n-1) \) moves), move the largest disk (1 move), move \( n-1 \) disks back (\( H(n-1) \) moves).
3
Equation: \( H(n) = 2H(n-1) + 1 \)
4
Initial condition: \( H(1) = 1 \) (one disk takes one move).

Example 2: Bit Strings

Problem: How many bit strings of length \( n \) have no two consecutive 0s?

String of length n Starts with 1 Starts with 0 Remaining: length n-1 Must be "01...", remaining length n-2 a(n-1) ways a(n-2) ways a(n) = a(n-1) + a(n-2)

Bit Strings Recurrence

1
Define: \( a(n) \) = number of valid bit strings of length \( n \) with no two consecutive 0s.
2
Equation: \( a(n) = a(n-1) + a(n-2) \) (Fibonacci-like!)
3
Initial conditions: \( a(1) = 2 \) (strings: 0, 1) and \( a(2) = 3 \) (strings: 01, 10, 11).

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.

1
Define: \( B(n) \) = balance after year \( n \).
2
Relationship: After one year, last year's balance earns 5% interest, then you add $200.
3
Equation: \( B(n) = 1.05 \cdot B(n-1) + 200 \)
4
Initial condition: \( B(0) = 1000 \)

Common Mistakes

✕ Vague Definition
Saying "let \( a(n) \) be the answer" without specifying what it counts. Always define \( a(n) \) precisely.
✕ Forgetting Initial Conditions
Writing the equation but never stating \( a(0) \), \( a(1) \), etc. Without them the recurrence is incomplete.
✕ Wrong Index Shift
Confusing \( a(n-1) \) with \( a(n) \), or using \( a(n+1) \) when the problem describes going backwards. Be consistent.

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?