Starting from:

$10

TowersOfHanoi.java

Represents the classic Towers of Hanoi puzzle.The classic Towers of Hanoi problem. Note how simple the core "MoveTower" method is. compare this to the non recursive solution ot the Towers Of Hanoi. Sets up the puzzle with the specified number of disks. Performs the initial call to moveTower to solve the puzzle. Moves the disks from tower 1 to tower 3 using tower 2. Moves the specified number of disks from one tower to another by moving a subtower of n-1 disks out of the way, moving one disk, then moving the subtower back. Base case of 1 disk. Prints instructions to move one disk from the specified start tower to the specified end tower.

More products