Towers of Hanoi
8.6 Towers of Hanoi: In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order of size from top to bottom (Le., each disk sits on top of an even larger one). You have the following constraints:
We can solve Towers of Hanoi by solving the smaller associated sub problems. For example, if we have 4 disks and 3 rods [A, B, and C]
, then we can reduce that problem by:
Move the top n-1 disks from A to B
Move the nth disk from A to C.
Move the n-1 disks from B to C.
Even though moving 3 disks at a time is an illegal move, this process is repeated (recurred on) until there is 1 disk, in which case the top disk will move from A to C. The same goes for the third step.
Last updated