2011Winter2009_Assignment3_solution

2011Winter2009_Assignment3_solution - Department of...

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

View Full Document Right Arrow Icon
1 Department of Computer Science and Engineering York University, Winter 2009 CSE 2011: Assignment 3 Due Date - Saturday, May 23, 7pm! Question 1 3-ary Tree [35 points] Let T be a full 3-ary tree (see Figure 1); that is, each parent has exactly 3 children. Let H(n) denote the height of this tree, where n represents the number of nodes in the tree. Prove the following is true for all full 3-ary trees: H(n) = log 3 (2 n+1) -1 Hint: use induction! Figure 1 Full 3-are tree Answer: Use induction. Case: n=1 H(1) = log 3 (2*1+1) – 1 = 0 - OK! Case: n=2 CANNOT BE! We cannot have 2 nodes in 3-ary tree. New valid n: When adding new set of nodes (at n+1 level), every node at level 1 will now become the root of a sub-tree that is identical to the entire tree of step n. Hence, n new = 3*n prev + 1 n prev = (n new -1)/3 Case: n=4 H(4) = log 3 (2*4+1) – 1 = 1 - OK! Case: n H(n) = H(n prev ) + 1 = = log 3 (2*n prev +1) -1 + 1 = = log 3 (2*(n new -1)/3 + 1) = = log 3 ((2*(n new -1)+3)/3) = = log 3 ((2*n new +1) - 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 10/30/2010 for the course CSE 2011 taught by Professor Nguyen during the Spring '10 term at Maple Springs Baptist Bible College.

Page1 / 3

2011Winter2009_Assignment3_solution - Department of...

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