In class we did an inductive proof to show that a full binary tree with n nodes has (n+1)/2 leaves. It looked something like this:
Base case: A tree containing only 1 node is full and has (1+1)/2=1 leaves. Inductive step: If a full binary tree with 1<=r<=k nodes has (r+1)/2 leaves, then a full binary tree with k+1 nodes has (k+2)/2 leaves. Proof: Consider a full binary tree T with k+1 nodes, k>=1.
Show that a proper binary tree with n nodes has (n+1)/2 leaves.Base case: A tree containing only 1 node is proper and has (1+1)/2=1 leaves.
Inductive step: If a proper binary tree with _____________ nodes has __________ leaves, then a proper binary tree with _____________ nodes has ______________ leaves. Proof: Consider a proper binary tree T with k+1 nodes, k>=1.
- Since T is proper and has more than one node, it consists of a root plus two subtrees, each of which is also a proper binary tree. Call the left subtree T1 and the right subtree T2.
- T1 and T2 are both proper, but they do not need to have the same number of nodes. Suppose that T1 has x nodes, x>=1. Then T2 must have ____________ nodes. (Hint: All the nodes in the tree except the root and those in T1.)
- By the inductive hypothesis, T1 must have ______________ leaves and T2 must have _________________ leaves.
- Since all of the leaves in T are in either T1 or T2, T must contain __________________ + ____________________ =_________________________________________________________ leaves.(Show simplification)