Question: One solution is already posted on this webiste which is very complicated. I don't want that one. I am looking for a different solution and
One solution is already posted on this webiste which is very complicated. I don't want that one. I am looking for a different solution and a different algorithm for the same puzzle but more simple.
The puzzle called the Towers of Hanoi consists of three pegs, one of which contains several rings stacked in order of descending diameter from bottom to top. The problem is to move the stack of rings to another peg. You are allowed to move only one ring at a time, and at no time is a ring to be placed on top of a smaller one. Observe that if the puzzle involved only one ring, it would be extremely easy. Moreover when faced with the problem of moving several rings, if you could move all but the largest ring to another peg the largest ring could then be placed on the third peg, and then the problem would be to move the remaining rings on top of it. Using this observation develop a recursive algorithm for solving the Towers of Hanoi puzzle for an arbitrary number of rings.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
