Write a recursive solution to towers of hanoi problem -


Question: A toy that many children play with is a base with three pegs and five disks of different diameters. The disks begin on one peg, with the largest disk on the bottom and the other four disks added on in order of size.

The idea is to move the disks from the peg they are on to another peg by moving only one disk at a time and without ever putting a larger disk on top of a smaller one. This child''s toy is actually an example of a classic mathematical puzzle called the Towers of Hanoi problem.

Write a recursive solution to this problem. It may take you a while to see the solution, but the program itself is quite short.

Input- The program should prompt for and input the number of Rings. For this program please use 3 pegs and 5 rings.

Output- The series of moves should be written to the screen, properly labeled.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Write a recursive solution to towers of hanoi problem -
Reference No:- TGS01274990

Now Priced at $30 (50% Discount)

Recommended (98%)

Rated (4.3/5)