Question: Exercise 4: Nonempty Binary Trees are defined by the conditions: - if a is a nonnegative integer then BinTree(a) is Nonempty Binary Tree. - If

Exercise 4: Nonempty Binary Trees are defined by the conditions: - if a is a nonnegative integer then BinTree(a) is Nonempty Binary Tree. - If t1 and t2 are Nonempty Binary Trees, and n is a nonnegative integer, then BinTree (t1,n,t2) is a Nonempty Binary Tree. Prove by structural induction that in every Nonempty Binary Tree, nodes(t)2height(t)1. Function nodes and height are defined by the conditions: nodes(BinTree(a))=1;nodes(BinTree(t1,n,t2))=1+nodes(t1)+nodes(t2).height(BinTree(a))=1;height(BinTree(t1,n,t2))=1+max(height(t1),height(t2)) Hints: 1. 2height(t1)2max(height(t1),height(t2)) 2. 2height(t2)2max(height(t1),height(t2)) 3. 2.2max(height(t1),height(t2))=21+max(height(t1),height(t2))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
