Exercises from Chapter 5 5.3 5.6 5.9 Solutions 5.3 Base case: n = 0. Then the tree consists of only one leaf, so E = 0 and I = 0, and the theorem holds. Induction step: assume n > 0 and the theorem holds for full binary trees with n-1 internal nodes. Take a tree T with n internal nodes. Since n > 0, T has internal nodes. Take an internal node v of T that has maximum depth d among all internal nodes. Because v is internal and T is full, v has two children, each of depth d+1. Because v has maximum depth among internal nodes, its children are leaves. Let U be the full tree that results from removing the two children of v, J = U's internal path length, and F = U's external path length. Since v is a leaf in U, U has n-1 internal nodes. By the induction assumption, F = J + 2(n-1). E = F + 2(d+1) - d = F + d + 2 because of the depths of v's two children and because v is no longer a leaf, and I = J + d because of v. Therefore E = F + d + 2 = J + 2(n-1) + d + 2 by our induction assumption = I - d + 2(n-1) + d + 2 = I +2n. 5.6 The main idea is to use a queue to hold the subtrees that will be printed: template void level(BinNode* subroot) { AQueue*> Q; Q.enqueue(subroot); while(!Q.isEmpty()) { BinNode* temp; Q.dequeue(temp); if(temp != NULL) { Print(temp); Q.enqueue(temp->left()); Q.enqueue(temp->right()); } } } 5.9 (a) Since all nodes have the same structure, the overhead fraction is 12/16 = 3/4. (b) 8/24 = 1/3. (c) Letting i be the number of internal nodes and l be the number of leaves, the overhead fraction is (12i + 4l)/(20i + 12l). For large full trees, this is aproximately 16/32 = 1/2. (d) Approximately 8/16 = 1/2.