pset 7 solve pdf 2

pset 7 solve pdf 2 - O Ryan Davis EECS 310 Problem Set 7...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
O Ryan Davis EECS 310 Problem Set 7 1.a) The maximum number of nodes of height h in a k-ary tree is k h for all h <= H and 0 for all h > H. We will first show that the number of nodes of height h in a k-ary tree of arbitrary k is maximized when all interior nodes in the tree have k children. We show this by contradiction. Assume that the number of nodes of height h <= H is not maximized when each interior node has k children. Then it must be possible to increase the number of nodes at height h. But every interior node has k children, so we cannot add any nodes to the tree at any height h <= H, contradicting our initial assumption. Thus, the number of nodes of height h in the tree is maximized when all interior nodes in the tree have k children. Next, we build on the previous argument to prove by induction that the maximum number of nodes of height h in a k-ary tree is k h . Base Case: H = 0. The height of the tree is zero, so the tree is simply the root node. Since there is only one node in the graph, the maximum number of nodes at h = 0 is 1, which equals k 0 for an arbitrary k. For all h > 0, the number of nodes of degree h is also zero. Inductive Step: Assume that the maximum number of nodes of height h in a k-ary tree is k h for all h <= H and 0 for all h > H. We now perform induction on the maximum height of the tree and consider a graph with maximum height H + 1 (call this G H+1 and the graph with maximum height H G H ). By the inductive hypothesis, we know that the maximum number of nodes at height H in G H is k H . For G H+1 , each leaf of the graph with maximum height H becomes an interior node with k children, because we know that each interior node must have k children and each leaf of G H has height H. For each of the k H leaves in G H , we add k nodes as children, so the total number of nodes at height H+1 in G H+1 is k H *k = k H+1 . Since G H is a subgraph of G H+1 , the number of nodes at height h <= H in G H+1 remains the same as in G H , k h . For h=H+1, we have shown that the maximum number of nodes at h=H+1 is k H+1 , thus completing the proof. QED. b) A ternary tree is a k-ary tree with k =3. We know from part a) that the total number of nodes at height h <= H is k h . We can find the total number of nodes in the tree by summing over all heights of the tree the number of nodes at that height: Σ h=1,…, H 3 h The closed form solution of the above summation is (3 H+1 – 1)/2. We prove this by induction on H for the general case, Σ h=1,…, H k h = (k H+1 – 1)/(k – 1) Base Case: H = 0 Σ h=1,…, H k h = k 0 = 1 = (k 0+1 – 1)/(k – 1) = (k – 1)/(k – 1) = 1 Inductive Step: Assume Σ h=1,…, H k h = (k H+1 – 1)/(k – 1) holds for all k. We now prove for h+1. Σ
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2012 for the course ECON 101 taught by Professor N/a during the Fall '11 term at Middlesex CC.

Page1 / 6

pset 7 solve pdf 2 - O Ryan Davis EECS 310 Problem Set 7...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online