GATE / CS ARCHIVE

GATE CSE 2010 / QUESTION 10

Odd subtree sizes in a binary tree

Data Structures · Tree Properties & Traversals · Full GATE CSE 2010 paper

GATE 2010, Q10 1 mark · MCQ
Report issue

Tree Properties & Traversals

Question 10, GATE 2010: A binary tree has n nodes. Every node has an odd number of descendants, counting the node itself as its own descendant. How many nodes have exactly one child?
Options: (A) 0; (B) 1; (C) (n−1)/2; (D) n−1.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

The descendants of a node, including itself, form its subtree. If a node had exactly one child, its subtree size would be 1 plus the child’s odd subtree size, hence even. This contradicts the condition at that node. Therefore no node has exactly one child: 0, A.

The parity condition applies to every child subtree as well as the root. A leaf has subtree size 1, which is allowed. A node with two children has size 1+odd+odd, also odd. Exactly one child gives 1+odd, even, which is impossible; thus the hypothesis forces a full binary tree, although it need not be balanced or perfect.

Original paper, page 3