Tuesday, January 3, 2012

Tower of Hanoi using Stacks

Design an algorithm using stacks.
We have to move 64 disks from one pole to another. But there are some rules about how this should be done, which are:
  1. You can move only one disk at a time.
  2. For temporary storage, a third pole may be used.
  3. You cannot place a disk of larger diameter on a disk of smaller diameter
Theory:
Recursive:
Iterative:

No comments:

Post a Comment