
972 CHAPTER 13 Recursion
The element at index 7 (36) is larger than 34, so we call the recursiveBinary-
Search method, searching the left subarray. However, that left subarray is
empty. We have not found 34, so we return 1.
13.6 Programming Activity 2: The Towers of Hanoi
A well-known problem that lends itself to an elegant recursive formulation
is the Towers of Hanoi. Here it is:
■
There are three towers, which we can represent as the source tower,
the temporary tower, and the destination tower.
■
We have a stack of n disks piled on the source tower; all the disks
have a different diameter. The largest disk is at the bottom and the
smallest disk is at ...