PDA

View Full Version : Need a non-recursive solution for the Hanoi Problem



shodanjr_gr
25-10-04, 18:11
I got a small excersise for school tomorrow...i gota come up with a nonrecursive algorithm that solves the Hanoi Tower problem...

All ideas welcome :)

I need a simple algorithm that is easily understandable by someone that poseses very little programming knowledge...

Cliffraiser
25-10-04, 19:17
whats hanoi..

and whats a tower..... O_o :confused:

Spermy
25-10-04, 19:22
Tosser - Don't post something just for the sake of it.

1883. We are given a tower of eight disks (initially four in the applet below), initially stacked in increasing size on one of three pegs. The objective is to transfer the entire tower to one of the other pegs (the rightmost one in the applet below), moving only one disk at a time and never a larger one onto a smaller.

The puzzle is well known to students of Computer Science since it appears in virtually any introductory text on data structures or algorithms. Its solution touches on two important topics discussed later on:

recursive functions and stacks
recurrence relations
The applet has several controls that allow one to select the number of disks and observe the solution in a Fast or Slow manner. To solve the puzzle drag disks from one peg to another following the rules. You can drop a disk on to a peg when its center is sufficiently close to the center of the peg. The applet expects you to move disks from the leftmost peg to the rightmost peg.

GOOGLE IS YOUR FRIEND CLIFF.

MR S - Try here

http://www.cut-the-knot.org/recurrence/hanoi.shtml

Cliffraiser
25-10-04, 19:29
hehe, i had to do something similar to that a few years ago. Didn't take me too long to figure it out though. Ill see if i still have the word file with my explanation of solving it, and see if i can post it somehow.