... peg 1 as a temporary holding area.
The process ends when the last task involves moving n = 1 disk (i.e., the base case). This task is accomplished by moving the disk, without using a temporary holding area.
In Fig. 18.11, method solveTowers
(lines 5–22) solves the Towers of Hanoi, given the total number of disks (in this case 3
), the starting peg, the ending peg, and the temporary holding peg as parameters.
Get Java How To Program, Late Objects, 11th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.