View worked solution
Answer: 19
In any binary tree, there is a direct 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 children)
- be the number of nodes with child
- be the number of nodes with 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 total number of edges by summing the outgoing degrees of all nodes:
Equating the two expressions for the total number of edges:
Substitute Equation 1 into Equation 2:
Simplifying the equation by subtracting from both sides:
Given that the number of leaves :
Thus, the number of nodes in having two children is 19.
Free practice · Your answers on this page are not saved.
