HW6-solutions - EECS 203: DISCRETE MATHEMATICS Homework 6...

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

View Full Document Right Arrow Icon
EECS 203: DISCRETE MATHEMATICS Homework 6 Solutions 1. (4 points) A rooted ternary tree is either a single vertex (which is the root) or consists of three ternary trees T 1 ,T 2 ,T 3 with roots r 1 ,r 2 ,r 3 , a new root vertex r , and edges { r,r 1 } , { r,r 2 } , { r,r 3 } . What is the maximum number of vertices in a ternary tree with height h ? Your proof should be by induction. Solution: Let V ( n ) be the maximum number of vertices in a ternary tree with height n . Using the recursive definition of ternary tree we have: V (0) = 1 V ( n ) = 3 V ( n - 1) + 1 for n > 0 In order to make an educated guess at what T ( n ) might be, note that the maximum number of vertices at height 0 is 1, at height 1 is 3, and in general, at height h the maximum number of vertices is 3 h . A good guess is that V ( n ) = 3 0 + 3 1 + ··· + 3 n = 3 n +1 - 1 2 . We prove this by induction. Base case: V (0) = 1 = 3 1 - 1 2 . General case: n > 0 Assume inductively that V ( n 0 ) = 3 n 0 +1 - 1 2 for all n 0 < n . Then: V ( n ) = 3 V ( n - 1) + 1 { def of V } = 3( 3 n - 1 2 ) + 1 { inductive assumption } = 3 n +1 - 3 2 + 1 = 3 n +1 - 1 2 { algebra } 2. (4 points) The sequence ( a 0 ,a 1 ,... ) is defined recursively as follows: a 0 = 0 and, for n > 0, a n = ± a n/ 2 for n even 1 + a ( n - 1) / 2 for n odd Prove by induction that a n is the number of 1s in the binary representation of n . Solution: Let ( b m b m - 1 ...b 1 b 0 ) 2 be the binary representation of n (each b i is a bit). Note that (i) if n is odd then b 0 = 1 and n - 1 = ( b m ...b 1 0) 2 and (ii) if n is even then b 0 = 0 and n/ 2 = ( b m ...b 1 ) 2 . Proof by induction: The base case is
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/20/2010 for the course EECS 203 taught by Professor Yaoyunshi during the Fall '07 term at University of Michigan.

Page1 / 4

HW6-solutions - EECS 203: DISCRETE MATHEMATICS Homework 6...

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