CS336f109

# CS336f109 - Inductive Proofs Lecture 9 CS336 TREES Prove(w1...

This preview shows pages 1–3. Sign up to view the full content.

9/27/10 1 Lecture 9 CS336 TREES Inductive Proofs Prove #( w 1 ^ w 2 ) = # w 1 + # w 2 • Base Case w 2 = λ Show #( w 1 ^ λ ) = # w 1 + # λ Show #( w 1 ^ λ ) = # w 1 + # λ #( w 1 ^ λ ) = <^.0> # w 1 = <+.0·> # w 1 +0 = <#.0‚> # w 1 + # λ Assume the IH, #( w 1 ^ w 2 ) = # w 1 + # w 2 , to show #( w 1 ^ w 2 x) = # w 1 + # w 2 x #( w 1 ^ w 2 x) = <^.1> # (( w 1 ^ w 2 )x) = <+.1> # ( w 1 ^ w 2 ) +1 = <IH> (# w 1 + # w 2 )+1 = < assoc. ; #.1> # w 1 + # w 2 x Hence by the PMI, QED. What’s Wrong? ( Σ i| 0 i<n: y=i) N+1< x+1 N<x N<x N<3 1<N<3 1<N A<B C<D A+C<B+D An inductive deﬁnition of FULL BINARY trees 1. (d, , ) is a full binary tree. 2. If t1 and t2 are full binary trees, then (d,t1,t2) is a full binary tree. ( I usually call (t1) l (left subtree) and (t2) r (right subtree) 3. TUEC

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

View Full Document
9/27/10 2 Functions • Height of Tree • Number of Nodes • Number of internal Nodes • Number of Leaves The Tree’s height h:: t →Ν h.0 h(d, , )= h.1 h(d,l,r)= The Tree’s height h:: t →Ν h.0 h(d, , )=0 h.1 h(d,l,r)= Max(h(l),h(r)) +1 The number of nodes of a binary tree #N:: t →Ν #N.0 #N(d, , )= #N.1 #N(d,l,r)= The number of nodes of a binary tree #N:: t →Ν #N.0 #N(d, , )=1 #N.1 #N(d,l,r)= #N(l)+ #N(r) +1 The number of leaves of a binary tree #L:: t →Ν #L.0 #L(d, , )= #L.1 #L(d,l,r)=
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

CS336f109 - Inductive Proofs Lecture 9 CS336 TREES Prove(w1...

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

View Full Document
Ask a homework question - tutors are online