<<

THE TOWER OF

MATH CIRCLE 3/27

The Summary

The Tower of Hanoi is an old mathematical (with an even older legend behind it, about an Indian temple and the end of the world). Here is the puzzle: Given a tower of some number of discs, stacked in decreasing size on one of three pegs, try to transfer the entire tower to one of the other pegs, moving only one disk at a time and never moving a larger disc onto a smaller. We will solve this puzzle hands-on and then using a mathematical idea called “recurrence relations.”

The Puzzle

There are 3 pegs and 8 discs with different diameters. The discs are all stacked on one of the pegs. In the stack, they are ordered by size: smallest on top, largest on the bottom. The goal is to move this tower onto one of two free pegs, by the following rules: • Only one disc may be moved at a time, • A larger disc may never be stacked onto a smaller disc.

Question 1. Is there a solution to this puzzle? In other words, is there a way to transfer all the discs to another peg according to the given rules? Question 2. How many moves are necessary and sufficient in order to solve this problem? Question 3. Can you come up with a formula or directions for how to solve this puzzle?

Answers

Question 1: Do you think this problem has a solution? Try it with the provided.

1 2 MATH CIRCLE 3/27

Question 2: How many moves does it take? Generalize. Instead of 8 discs, what if we ask the question with 1 disc? Two discs? Three discs? n discs? n = 1 is completely trivial (only 1 move)! n = 2 it’s fairly easy to see it takes 3 moves. n = 3 How many moves are required?

Let Tn := the minimum number of moves necessary to move n blocks according to the rules given. It’s fairly easy to see that in our small cases above, we couldn’t have solved the puzzle in fewer moves. Therefore, we know that

T0 = 0 T1 = 1 T2 = 3 T3 =

Find a pattern. By experimenting again, we can determine that one way to move n discs is to • move n − 1 discs onto the middle peg, • move the last disc onto the desired peg, • move the n − 1 discs onto the last disc.

These three steps require Tn−1, 1, and Tn−1 moves, respectively. We can thus conclude that

Tn ≤ 2Tn−1 + 1 for n > 0.

Can we do any better than this? Can you find a formula for Tn in terms of Tn−1?

What we’ve found at this point is called a “.” We can use it to compute Tn for any n that we like. For instance, how many moves does it take to transfer 6 discs?

This is a lot of work, so let’s see if we can do better. THE TOWER OF HANOI 3

Solve the recurrence. Let’s first look at small cases to see if we can discern a pattern:

T3 = 2 · 3 + 1 = 7 T4 = 2 · 7 + 1 = 15 T5 = 2 · 15 + 1 = 31 T6 = 2 · 31 + 1 = 63 For n ≤ 6 at least, we see that n Tn = 2 − 1. To prove that this is true for all n, use mathematical induction!! (Which we did in a previous math circle). Show your proof by mathematical induction here:

Question 3: Can you come up with directions for how to solve this puzzle?

Try drawing a graph to show which moves you can make. Start with small examples like n = 1 and n = 2. 4 MATH CIRCLE 3/27

If it helps, check out these graphs for solving the problem. Can you come up with an n = 3 graph?

As the graph expands, what does this remind you of? Hint: Remember the chaos game?

Sources

The material for this Math Circle is adapted from §1.1 of Concrete Mathematcs: A Foundation for Computer Science by Graham, Knuth, Patashnik.