GATE Computer ScienceVery hardGATE CSE · NIELIT

A complete binary tree with 100 nodes (levels filled left to right, array positions 1 to 100) is given. Let X be the number of leaves and Y the number of nodes having exactly one child. What is X + Y?

  1. A. 51
  2. B. 50
  3. C. 52
  4. D. 49

Correct answer: A. 51

Leaves are positions 51–100 so X = 50 (internal nodes are 1–50). Position 50 has only left child 100, so Y = 1. X + Y = 51.

More Programming and Data Structures (GATE) questions

Exams that ask this topic