- #1
Jairo Rojas
- 17
- 0
Homework Statement
In a binary tree all nodes are either internal or they are leaves. In our definition, internal nodes always have two children and leaves have zero children. Prove that for such trees, the number of leaves is always one more than the number of internal nodes.
Homework Equations
The Attempt at a Solution
Proof by induction
Base case:
n=1
Number of leafs=1
External nodes=0
Induction step: Assume a binary tree has k internal nodes and k+1 leaves. Therefore we have to show that a binary tree with k+1 internal nodes will have (k+1)+1 leaves
If we want to increase the number of external nodes by 1 in this binary tree, we would have to make a leaf an internal node and we do this by sticking two new leaves to an old leaf. Doing this the net change in leaves is 1 because we eliminate 1 and add 2 new. So the number of external nodes is k+1 and the number of leaves is (k+1)+1. Consequently, by induction, the number of leaves is always one more than the number of internal nodes in a binary tree.
Is that correct?