Java Reference
In-Depth Information
a. The original maze is defined.
b. A test to see if we have arrived at the goal occurs.
c. A location is marked as having been tried.
d. A test to see if we already tried a location occurs.
SR 12.13 Trace the MazeSearch program to determine the series of calls to
the method valid (including the values of the parameters that are
passed) that would occur if the original maze is as shown.
a. 1 1
1 1
b. 0 0
0 0
c. 1 1
1 0
SR 12.14 Explain the general approach to solving the Towers of Hanoi puzzle.
How does it relate to recursion?
SR 12.15 Trace the SolveTowers code for an initial stack of 1 disk. How many
calls to the moveTower method are made? How many calls are made
for an initial stack of 2 disks? How many for 3 disks? Describe a
pattern related to the number of calls made to the moveTower method
as the number of disks increases.
12.4 Recursion in Graphics
The concept of recursion has several uses in images and graphics. The following
section explores some image and graphics-based recursion examples.
Tiled Pictures
Carefully examine the display for the TiledPictures applet shown in Listing 12.5.
There are actually three unique images among the menagerie. The entire area is
divided into four equal quadrants. A picture of the world (with a circle indicat-
ing the Himalayan mountain region) is shown in the bottom-right quadrant. The
bottom-left quadrant contains a picture of Mt. Everest. In the top-right quadrant
is a picture of a mountain goat.
The interesting part of the picture is the top-left quadrant. It contains a copy
of the entire collage, including itself. In this smaller version you can see the three
simple pictures in their three quadrants. And again, in the top-left corner, the
picture is repeated (including itself). This repetition continues for several levels. It
is similar to the effect you can create when looking at a mirror in the reflection
of another mirror.
 
Search WWH ::




Custom Search