View worked solution
Answer: 199
In any binary tree, there is a strict relationship between the number of leaf nodes (nodes with degree 0) and the number of nodes with exactly two children.
Let:
- be the number of leaf nodes (nodes with 0 children)
- be the number of nodes with exactly 1 child
- be the number of nodes with exactly 2 children
The total number of nodes in the tree is:
Since every node except the root has exactly one incoming edge, the total number of edges in a tree with nodes is . We can also count the edges by looking at the children of each node:
Equating the two expressions for the total number of edges:
Simplifying the equation by subtracting from both sides:
Given that the number of leaf nodes :
Thus, the number of nodes in that have exactly two children is 199.
Free practice · Your answers on this page are not saved.
