Java Reference
In-Depth Information
F IGURE 20.17
The program displays a solution to the Eight Queens problem.
**20.35
( H-tree fractal ) An H-tree (introduced at the beginning of this chapter) is a
fractal defined as follows:
1. Begin with a letter H. The three lines of the H are of the same length, as
shown in Figure 20.1a.
2. The letter H (in its sans-serif form, H ) has four endpoints. Draw an H centered
at each of the four endpoints to an H-tree of order 1 , as shown in Figure
20.1b. These Hs are half the size of the H that contains the four endpoints.
3. Repeat Step 2 to create an H-tree of order 2 , 3 , . . . , and so on, as shown in
Figure 20.1c-d.
Write an applet that draws an H-tree, as shown in Figure 20.1.
**20.36
( Hilbert curve ) The Hilbert curve, first described by German mathematician
David Hilbert in 1891, is a space-filling curve that visits every point in a square
grid with a size of or any other power of 2.
Write a Java applet that displays a Hilbert curve for the specified order, as
shown in Figure 20.18.
2
*
2, 4
*
4, 8
*
8, 16
*
16,
(a)
(b)
(c)
(d)
F IGURE 20.18
A Hilbert curve with the specified order is drawn.
20.37
( Sierpinski triangle ) Write a program that prompts the user to enter the order
and display the filled Sierpinski triangles as shown in Figure 20.19.
**20.38
( Recursive tree ) Write an applet to display a recursive tree as shown in
Figure 20.20.
 
Search WWH ::




Custom Search