...

/

Towers of Hanoi, continued

Towers of Hanoi, continued

We'll cover the following...

When you solved the Towers of Hanoi for three disks, you needed to expose the bottom disk, disk 33, so that you could move it from peg A to peg B. In order to expose disk 33, you needed to move disks 11 and 22 from peg A to the spare peg, which is peg C:

widget

Wait a minute—it looks like two disks moved in one step, violating the first rule. But they did not move in one step. You agreed that you can move disks 11 and 22 from any peg to any peg, using three steps. The situation above represents what you have after three steps. (Move disk 1 from peg A to peg B; move disk 22 from peg A to peg C; move disk 11 from peg B to peg C.)

More to the point, by moving disks 11 and 22 from peg A to peg C, you have recursively solved a subproblem: move disks 11 through n1n-1 (remember that n=3n = 3) from peg A to peg C. Once you've solved this subproblem, you can move disk 33 from peg A to peg B:

widget

Now, to finish up, you need to recursively solve the subproblem of moving disks 11 through n1n-1 from peg C to peg B. Again, you agreed that you can do so in three steps. (Move disk 11 from peg C to peg A; move disk 22 from peg C to peg B; move disk 11 from peg A to peg B.) And you're done:

widget

And—you knew this question is coming—is there anything special about which pegs you moved disks 11 through 33 from and to? You could have moved them from any peg to any peg. For example, from peg B to peg C:

  • Recursively solve the subproblem of moving disks 11 ...