CS336f109 - 9/27/10 Inductive Proofs Lecture 9 CS336 TREES...

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

View Full Document Right Arrow Icon
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 definition 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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)=
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2010 for the course CS 336 taught by Professor Myers during the Fall '08 term at University of Texas at Austin.

Page1 / 6

CS336f109 - 9/27/10 Inductive Proofs Lecture 9 CS336 TREES...

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

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