Question: Using Java , implement a non-recursive algorithm for Tower of Hanoi Puzzle for input size 'n' disks. The algorithm should display the moves performed to
Using Java, implement a non-recursive algorithm for Tower of Hanoi Puzzle for input size 'n' disks. The algorithm should display the moves performed to move 'n' disks from initial peg to goal peg. Implementation must be non-recursive algorithm!
Implement for input size of n = 6, n = 10, n = 20 please.
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:
-------> 
OUTPUT (should look like below): Move the disk 1 from 'A' to 'C' Move the disk 2 from 'A' to 'B' Move the disk 1 from 'C' to 'B' Move the disk 3 from 'A' to 'C' .... ....
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
