Question: Using Java , implement a non-recursive algorithm for Tower of Hanoi Puzzle for input size 'n' disks. The algorithm should ask the user to input
Using Java, implement a non-recursive algorithm for Tower of Hanoi Puzzle for input size 'n' disks. The algorithm should ask the user to input the size for 'n' and display the moves performed to solve the puzzle. Implementation must be non-recursive algorithm!
What is Tower of Hanoi Puzzle? You are given a set of three pegs and n disks, with each disk a different size. Let's name the pegs A, B, and C, and let's number the disks from 1, the smallest disk, to n, the largest disk. At the outset, all n disks are on peg A, in order of decreasing size from bottom to top, so that disk n is on the bottom and disk 1 is on the top. The goal is to move all n disks from peg A to peg B.
Conditions: 1. You may move only one disk at a time. 2. No disk may ever rest atop a smaller disk. For example, if disk 3 is on a peg, then all disks below disk 3 must have numbers greater than 3.
Example:
------->
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
