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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started