How many times is the moveDisks method in Listing invoked for moveDisks(5, 'A', 'B', 'C')?
Listing


This problem is inherently recursive. Using recursion makes it possible to find a natural, simple solution. It would be difficult to solve the problem without using recursion. Consider tracing the program for n = 3. The successive recursive calls are shown in Figure. As you can see, writing the program is easier than tracing the recursive calls. The system uses stacks to manage the calls behind the scenes. To some extent, recursion provides a level of abstraction that hides iterations and other details from the user.

Invoking moveDisks(3, 'A', 'B', 'C') spawns calls to moveDisks recursively.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.