In a binary tree with nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child?
View worked solution
Answer: A
Let denote the number of descendants of a node . By definition, a node is its own descendant, so we can express recursively as:
where if the left child does not exist, and if the right child does not exist.
We are given that for every node in the binary tree, must be an odd number. Let's analyze the three possible cases for any node :
- is a leaf node (0 children):
, which is odd. (Valid) - has exactly two children:
Since both children are nodes in the tree, their descendant counts and must both be odd.
, which is odd. (Valid) - has exactly one child:
Without loss of generality, let have only a left child. Since the left child is a node, its descendant count must be odd.
.
This contradicts the given condition that must be odd for every node.
Thus, no node in the tree can have exactly one child. The number of such nodes is .
Free practice · Your answers on this page are not saved.
