Project 1: Towers of Hanoi



In this project, you will implement a stack ADT and use it. Towers of Hanoi is a mathematical game which consists of three rods and a number of disks of different sizes which can slide onto any rod. In the beginning, the disks are neatly stacked in order of size on one rod, with the smallest at the top (see figure).

The objective of the game is to move the entire stack to another rod, obeying the rules:
  1. Only one disk may be moved at a time.
  2. Each move consists of taking the upper disk from one of the rods and sliding it onto another rod, on top of the other disks that may already be present on that rod.
  3. No disk may be placed on top of a smaller disk.
You are expected to implement two algorithms to solve this puzzle for n disks:
  1. Using recursion (this one will be quite simple)
  2. Without using recursion: Here, we expect you to implement recursion by hand. We expect you to use a stack to emulate the recursive call. Please do not use other non-recursive solutions that you may find on the internet.
TA Feedback:
  1. Do not submit files if there not in .java format.
  2. Be sure that the name of the file corresponds to the class. Compile and check before submitting.
  3. Give output in the format as and when specified and include NO extra words.
  4. Be user to make it as user friendly as possible. eg: in this case, the number of disks should have been specified by the user.
  5. STRICTLY KEEP TO FORMAT OF ALL FILES IN A FOLDER AND THEN ZIP THAT FOLDER. If you submit C solutions, submit separately in a different folder with name "roll.num_c sol".
  6. Name all folders just the last 4 digits of the rollnumber. eg: if your roll number is P2008CS1083, just name the folder 1083.
Individual Feedback