Question: Prove that the original recursive Tower of Hanoi algorithm performs exactly the same sequence of movesthe same disks, to and from the same pegs, in
Prove that the original recursive Tower of Hanoi algorithm performs exactly the same sequence of movesthe same disks, to and from the same pegs, in the same orderas each of the following non-recursive algorithms. The pegs are labeled 0, 1, and 2, and our problem is to move a stack of n disks from peg 0 to peg 2
(a) If n is even, swap pegs 1 and 2. At the ith step, make the only legal move that avoids peg i mod 3. If there is no legal move, then all disks are on peg i mod 3, and the puzzle is solved
Use induction n to show that this non-recursive method performs exactly the same entries and the recursive method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
