(438 Views)

Tower of Hanoi, is a mathematical puzzle which consists of three towers.These rings are of varying sizes sizes and stacked upon each other in ascending order. There are other variations of the puzzle where the number of disks increase, but the tower count remains the same.

Source: Wikipedia

A few rules that need to be followed for Tower of Hanoi are -

1.The top disk can be moved only. 2.Only one disk can be moved at a time. 3.No large disk sits above a small disk.

With 3 disks, the puzzle can be solved in 7 moves. The minimal number of moves required to solve a Tower of Hanoi puzzle is 2^{n} ? 1, where n is the number of disks.

In the above algorithm,

- Consider three towers source, dest, aux and take value of disks from the user.
- Now we move all the above n-1 disks one by one from source to aux.
- The largest disk is left at the source, which is then moved to the dest tower.
- Then again the rest of the disks are moved back from aux to source.
- Again the same steps are repeated so that all the disks are moved to the dest tower.

1 UpvotesUpvote |
0 DownvotesDownvote |

- How to Install VirtualBox Guest Additions on Debian 9 Virtual Machine (VM) [682 Views]
- Download DIGITAL SIGNAL PROCESSING by Ashok Ambardar PDF [1496 Views]
- Bellman-Ford Algorithm with Example [11650 Views]
- How to give Android Permission for I/O Operations over NFC [740 Views]
- Download AngularJS Up & Running by Shyam Seshadri & Brad Green PDF [2226 Views]

- Knuth-Morris-Pratt (KMP) Substring Search Algorithm with Java Example [23462 Views]
- How To Win Ludo King Game Every Time [23300 Views]
- Algorithm to find whether number is Armstrong Number or Not [21998 Views]
- Jio Phone hang on LOGO problem Solution - Hard Reset Jio Phone [14504 Views]
- error: Multiple commands produce error in Xcode 10 [12290 Views]