GATE Computer ScienceVery hardGATE CS (PYQ pattern)

How many structurally distinct binary trees (left and right children distinguished) with exactly 7 nodes have exactly 3 leaves?

  1. A. 105
  2. B. 134
  3. C. 120
  4. D. 84

Correct answer: C. 120

3 leaves means 2 two-child nodes and 7 - 3 - 2 = 2 one-child nodes. Count = C(6,4) x C_2 x 2^2 = 15 x 2 x 4 = 120: choose the shape pattern, then left or right for each one-child node (the Narayana count 105 is for plane trees, not binary trees).

More Programming and Data Structures (GATE) questions

Exams that ask this topic