- 2073 Magh · 5 marks
Set up recurrence for Tower of Hanoi
Short answer
For n discs, the minimum number of moves H_n satisfies H_n = 2H_{n-1} + 1 for n ≥ 2, with H_1 = 1.
Setup a recurrence relation for the sequence representing the number of moves needed to solve Hanoi Tower puzzle.
Puzzle: n discs of different sizes are on peg A, largest at the bottom. Move all to peg C using peg B, moving one disc at a time and never placing a larger disc on a smaller one.
Let Hₙ be the minimum number of moves for n discs.
Setting up the recurrence
- Move the top n − 1 discs from A to B (using C): Hₙ₋₁ moves.
- Move the largest disc from A to C: 1 move.
- Move the n − 1 discs from B to C (using A): Hₙ₋₁ moves.
Step 1: top n-1 discs A -> B (Hn-1 moves)
Step 2: largest disc A -> C (1 move)
Step 3: n-1 discs B -> C (Hn-1 moves)
A B C
[1]
[2] start (n = 3)
[3]
A B C
[3] [1]
[2] after step 1
A B C
[1] [3]
[2] after step 2
Hence
Hₙ = 2Hₙ₋₁ + 1, for n ≥ 2, with H₁ = 1 (or H₀ = 0).
It is a linear non-homogeneous recurrence of order 1. Values: H₁ = 1, H₂ = 3, H₃ = 7, H₄ = 15, H₅ = 31. Solving it by repeated substitution gives Hₙ = 2ⁿ − 1.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Derive and solve Tower of Hanoi recurrence · Discrete Structure, chapter 3
- What is a recurrence relation · Discrete Structure, chapter 3 · asked 2×
- Solve third-order recurrence with n·4ⁿ · Discrete Structure, chapter 3 · asked 6×
- Recursion tree for Tower of Hanoi, 4 disks · Data Structure and Algorithm, chapter 5