Question: The stack ADT can also be leveraged to greatly simplify any program that requires a collection of items where operations only occur on one end.

The stack ADT can also be leveraged to greatly simplify any program that requires a collection of items where operations only occur on one end. It is a great ADT choice simulating a puzzle where you stack objects on top of one another, such as the Tower of Hanoi. In this assignment, you will be responsible for two parts: Part 1: implement your own version of the stack ADT using linked nodes. Implement all necessary public methods - at minimum, you will need push, pop, and toString. Part 2: design and implement the logic needed to move disks from tower to tower for a simple, user-driven, simulation of the puzzle Tower of Hanoi

Sample output: stack 1: [3, 2, 1] stack 2: [] stack 3: [] Choose a tower to move FROM: ("1 - 3") 1 Choose a tower to move TO: ("1 - 3") 2 stack 1: [3, 2] stack 2: [1] stack 3: [] Would you like to move another disk? (y/n) y Choose a tower to move FROM: ("1 - 3") 1 Choose a tower to move TO: ("1 - 3") 3 stack 1: [3] stack 2: [1] stack 3: [2] Would you like to move another disk? (y/n) n Process finished with exit code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!