People think that computer science is the art of geniuses but the actual reality is the opposite, just many people doing things that build on each other, like a wall of mini stones. Donald Knuth

Tower Of Hanoi

Language Java | Level Intermediate | Category Data structure | August 30, 2015 1:33 pm


Data structure Description

Tower Of Hanoi is a mathematical game which consists three rods. The rods has a number of disk with the different size which can slide onto any rod. The objective of the puzzle is to move the entire stack to another rod. It should follow

  1. Only one disk can be moved at a time.
  2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack.
  3. No disk may be placed on top of a smaller disk.>/li>

Write a program to implement Tower Of Hanoi which move the disks from source to destination using the stack.


Output

   					 

Enter number of discs: 3
A -> C
A -> B
C -> B
A -> C
B -> A
B -> C
A -> C

				    

Comments


No comments available!

Please login to add comments.