Java Reference
In-Depth Information
F
IGURE
18.17
The program displays a solution to the Eight Queens problem.
**18.35
(
H-tree fractal
) An H-tree (introduced at the beginning of this chapter in
Figure 18.1) 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 18.1a.
2. The letter H (in its sans-serif form, H) has four endpoints. Draw an H cen-
tered at each of the four endpoints to an H-tree of order
1
, as shown in
Figure 18.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 18.1c-d.
Write a program that draws an H-tree, as shown in Figure 18.1.
18.36
(
Sierpinski triangle
) Write a program that lets the user to enter the order and
display the filled Sierpinski triangles as shown in Figure 18.18.
F
IGURE
18.18
A filled Sierpinski triangle is displayed.
**18.37
(
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 2
16, or any other power of 2.
Write a program that displays a Hilbert curve for the specified order, as shown
in Figure 18.19.
*
2, 4
*
4, 8
*
8, 16
*
Search WWH ::
Custom Search