solve3 - CSE2011F06/HR Solution of#3 1 Answer the following...

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

View Full Document Right Arrow Icon
CSE2011F06/HR - Solution of #3 1. Answer the following questions about a non-empty. .. a. By induction on N : Base case N=1 : if the tree has only one node, that node must have two null links, so the equality holds. Now assume the equality holds for N-1 . Given a tree with N nodes, remove one of its leaves. This reduces it to a tree with N-1 , which, by the induction hypothesis, must have N-1+1=N null links. When we return the leaf that we took out, we would have increased this count by 2 (being the links of the leaf node) and decreased it by 1 (being the link of leaf's parent). So returning the leaf increases the count by 1, making it N+1 , which is claim. b. Let us count the number of edges (i.e. non-null links) in the tree: By looking at the children of each node, this number is clearly: 2*n 2 + 1*n 1 + 0*n 0 where n i is the number of nodes with i children. But by looking at the parent of each node, this same number must be: N-1 because each node but the root has a parent. By equating these two (and noting that N = n 2 + n 1 + n 0 ), we prove the claim. c. By induction on H : Base case H=0 : in this case the tree has only one node and the claim becomes 1 ≤ 1 , which is true. Now assume the claim holds for any height up to H-1 (strong induction). Given a tree with H , remove its root. This reduces it to two trees each of which has
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 12/11/2010 for the course CSE CSE 2011 taught by Professor Neugyen during the Fall '09 term at York University.

Page1 / 3

solve3 - CSE2011F06/HR Solution of#3 1 Answer the following...

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