Java Reference
In-Depth Information
2.
A tree that represents the organization of this topic is a general tree, such as the following:
Book
Front pages
Chapters
Appendices
Index
Title page
Chapter 1
Appendix A
Opening pages
Sections
Summaries
Exercises
3.
3, 3, and 4, respectively.
a.
For the tree in Figure 23-6a,
n
is 7 and
h
is 3. Since the tree is full and 7
=
2
3
-
1, the relationship
n
=
2
h
-
1 is
true. Also, 3
=
log
2
(7
+
1), so the relationship
h
=
log
2
(
n
+
1) is true.
b.
For the tree in Figure 23-6b,
n
is 10 and
h
is 4. The tree is complete, and log
2
(10
+
1) is approximately 3.5,
which rounded up is 4. Thus, the relationship
h
=
log
2
(
n
+
1) rounded up is true.
4.
2
6
-
1, or 63.
5.
6.
log
2
(14
+
1) is approximately 3.9. When rounded up, we get 4
7.
Preorder: Jared, John, James, Mary, Jennifer, Robert, Carole
Postorder: James, Mary, John, Robert, Carole, Jennifer, Jared
Inorder: James, John, Mary, Jared, Robert, Jennifer, Carole
Level order: Jared, John, Jennifer, James, Mary, Robert, Carole
8.
1
2
3
4
5
6
11
7
8
9
10
14
12
13
15
16