Question:

Consider a binary tree \( T \) in which every node has either zero or two children. Let \( n%gt;0 \) be the number of nodes in \( T \). Which ONE of the following is the number of nodes in \( T \) that have exactly two children?

Show Hint

For a full binary tree, the number of internal nodes (nodes with two children) is always one less than the number of leaf nodes. Use the formula \( I = \frac{n-1}{2} \) for quick calculations in GATE.
Updated On: Apr 7, 2025
  • \( \frac{n - 2}{2} \)
  • \( \frac{n - 1}{2} \)
  • \( \frac{n}{2} \)
  • \( \frac{n + 1}{2} \)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

Given that every node in the binary tree has either zero or two children, this tree is known as a full binary tree. For a full binary tree with \( n \) nodes, the number of leaf nodes (\( L \)) and internal nodes (\( I \)) (nodes with exactly two children) satisfy the relation: \[ n = I + L \] A full binary tree with \( I \) internal nodes follows the property: \[ L = I + 1 \] Substituting \( L \) into the equation: \[ n = I + (I + 1) \] \[ n = 2I + 1 \] Solving for \( I \): \[ I = \frac{n - 1}{2} \] Thus, the number of nodes with exactly two children is: \[ \frac{n - 1}{2} \] which matches option (B).
Was this answer helpful?
0
0

Top Questions on Trees

View More Questions