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:
- Only one disk may be moved at a time.
- 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.
- 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:
- Using recursion (this one will be quite simple)
- 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:
- Do not submit files if there not in .java format.
- Be sure that the name of the file corresponds to the class. Compile and
check before submitting.
- Give output in the format as and when specified and include NO extra
words.
- 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.
- 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".
- 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