Java Reference
In-Depth Information
9.
(a) a b * c
*
(b) ( a b )
c
*
a
c
*
c
a
b
b
10.
Figure 23-14a
Preorder: / a b
Inorder: a / b
Postorder: a b /
Figure 23-14c
Preorder: * a + b c
Inorder: a
b + c
Postorder: a b c + *
*
Figure 23-14d
Preorder: / * a + b * c d e
Inorder: a * b + c * d / e
Postorder: a b c d * + * e /
11.
The tree in Figure 23-14a is full; the tree in Figure 23-14b is complete.
12.
17.
13.
The method learn augments the tree under conditions that the class GuessingGame must control. It would be
inappropriate for a client to invoke this method.
14.
5.
15.
The shortest tree has height 2; the tallest tree has height 3.
16.
The root of a maxheap contains the object with the largest value. If this object is unique in the set of objects, the
root is unique. If another object has the same value, it would be a child of the root. In Figure 23-20a, only 9 can be
the root.
17.
No. The order of siblings is not specified in a heap, so several different heaps can contain the same data. For
example, in Figure 23-20a, you could exchange 2 and 5, or you could exchange the root's two subtrees, and still
have a maxheap.
 
Search WWH ::




Custom Search