![]() Our ultimate aim is to move disk n from source to destination and then put all other (n1) disks onto it. The largest disk (n th disk) is in one part and all other (n-1) disks are in the second part. We divide the stack of disks in two parts. So now, we are in a position to design an algorithm for Tower of Hanoi with more than two disks. And finally, we move the smaller disk from aux to destination peg.Then, we move the larger (bottom) disk to destination peg.First, we move the smaller (top) disk to aux peg.If we have only one disk, then it can easily be moved from source to destination peg. We mark three towers with name, source, destination and aux (only to help moving the disks). To write an algorithm for Tower of Hanoi, first we need to learn how to solve this problem with lesser amount of disks, say → 1 or 2. This presentation shows that a puzzle with 3 disks has taken 2 3 - 1 = 7 steps. Tower of Hanoi puzzle with n disks can be solved in minimum 2 n−1 steps. ![]()
0 Comments
Leave a Reply. |