The Towers of Hanoi need little
introduction. Most Computer Scientists are familiar with the
legendary problem. This is a “fun” problem to attempt to do by hand
but in the realm of computing, recursion offers an straightforward and
elegant solution.
The graphics window displays three pegs. Initially all the disks
shall be on peg one, at each step in the execution the positioning of the
pegs will be updated until the problem is eventually solved.
The Code window displays the Java source code of the recursive method,
showing the flow of execution through the algorithm as the algorithm works
towards the solution.

In area A the Java source code for the recursive algorithm that solves
the problem of the Towers of Hanoi is displayed. As the algorithm
executes the current line of execution is highlighted.

This animation shows the way that the disks are stacked on the three pegs
at each point during the solution.

This is the the levels of recursion. This bar graph shows the current
level of recursion, (i.e. the number of recursive calls on the stack)
In the Towers of Hanoi can be anything up to a maximum depth of number
of disks plus one.

Gives a textual explanation of the line currently under execution
in A. Use the speed control bar (E) to slow down the algorithm so
that you can read each message and follow the "code walk through" at your
own pace.

Here you can adjust the number of disks that should be moved from peg 1
to peg 3.

This speed control allows you to speed up and slow down the rate at which
the algorithm executes.

