in reply to Recursion: The Towers of Hanoi problem
If we aren't allowed to put larger disks on top of smaller disks (as in the classic example above), you need an exponential number of moves. If T(n) is the number of moves needed to sort n disks, your recursion gives the recurrence T(n) = 2T(n-1). You can verify that T(n) = 2^n.
Towers of Hanoi problems are good examples in that they are easy to visualize, and their relationship to sorting with stacks is obvious.
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Visualizing (was Re^2: Visiting the Towers of Hanoi.)
by merlyn (Sage) on Oct 19, 2004 at 03:50 UTC |