0% found this document useful (0 votes)
93 views1 page

Exercise

The document describes the Tower of Hanoi puzzle and provides a solution for moving n disks from one peg to another using the shortest sequence of moves. It explains that the general strategy is to first move the top n-1 disks, then the bottom disk, and then move the top n-1 disks again. It also proves mathematically that the minimum number of moves required for n disks is 3n-1.

Uploaded by

rohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views1 page

Exercise

The document describes the Tower of Hanoi puzzle and provides a solution for moving n disks from one peg to another using the shortest sequence of moves. It explains that the general strategy is to first move the top n-1 disks, then the bottom disk, and then move the top n-1 disks again. It also proves mathematically that the minimum number of moves required for n disks is 3n-1.

Uploaded by

rohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Find the shortest sequence of moves that transfers a tower of n disks from the left peg A to the right

peg
C, using the middle peg B as a help, if direct moves between A and B are disallowed.

Solution. For n = 1 the shortest sequence is A → B, B → C. For n = 2 it is:

1. A → B.
2. B → C.
3. A → B.
4. C → B. Note that the whole tower is on peg B now.
5. B → A.
6. B → C.
7. A → B.
8. B → C.

For the general case, observe that the strategy that solves the problem for n disks works as follows:
1. Move the upper tower of n − 1 disks on peg C.
2. Move the n-th disk to peg B. 1
3. Move the upper tower of n − 1 disks on peg A.
4. Move the n-th disk to peg C.
5. Move the upper tower of n − 1 disks on peg C.

Let Xn be the number of moves which are necessary to solve the problem: then X 0 = 0 and XN≤ 3X0-1 + 2
for every n ≥ 0, and as the nth disk can only be moved when all the others have been moved, the
converse inequality must also hold. It is then easy to see, either by induction or by setting U n = Xn+1, that
the unique solution is Xn = 3n-1.

You might also like