How do we know the correct moves of Tower of Hanoi?
Posted
by
Saqib
on Stack Overflow
See other posts from Stack Overflow
or by Saqib
Published on 2012-03-19T10:13:16Z
Indexed on
2012/03/20
17:29 UTC
Read the original article
Hit count: 252
towers-of-hanoi
We know that:
In case of iterative solution: Alternating between the smallest and the next-smallest disks, follow the steps for the appropriate case:
For an even number of disks:
make the legal move between pegs A and B
make the legal move between pegs A and C
make the legal move between pegs B and C
repeat until complete
For an odd number of disks:
make the legal move between pegs A and C
make the legal move between pegs A and B
make the legal move between pegs B and C
repeat until complete
In case of recursive solution: To move n discs from peg A to peg C:
move n-1 discs from A to B. This leaves disc n alone on peg A
move disc n from A to C
move n-1 discs from B to C so they sit on disc n
Now the questions are:
How did we get this two solutions?
Only by intuition?
Or by logical/mathematical computation?
If computation, how?
© Stack Overflow or respective owner