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.length() == 0) { BinNode* temp; temp = Q.dequeue(); if(temp != NULL) { Print(temp); Q.enqueue(temp->left()); Q.enqueue(temp->right()); } } } 5.16 Add a node with value 5 as the right child of node 2. 5.17 Node 24 replaces node 7. 5.23 Minimum has only 1 node at level h-1, and the number of elements in levels 0 through h-2 is 1 + 2 + 2#2 + ... + 2#(h-2) = 2#(h-1) - 1, so total size = 2#(h-1). Maximum has 2#(h-1) nodes at level h-1, so total size = 2#(h-1) -1 + 2#(h-1) = 2#h - 1. 5.28 Reading off the leaves of the Huffman tree and their codes: L 00 H 010 I 011 E 1000 F 1001 J 101 D 11000 A 1100100 B 1100101 C 110011 G 1101 K 111 The average code length of a word of length n is 3.23445n.