GATE Computer ScienceModerateGATE CS (PYQ pattern)

How many binary search trees on the keys 1, 2, …, 9 have 4 at the root and 7 as the right child of the root?

  1. A. 20
  2. B. 210
  3. C. 42
  4. D. 25

Correct answer: A. 20

Left subtree of 4: keys 1–3, C₃ = 5 shapes. Right subtree: keys 5–9 with root 7, whose left subtree is {5, 6} (C₂ = 2) and right subtree is {8, 9} (C₂ = 2). Total 5 · 2 · 2 = 20.

More Discrete Mathematics questions

Exams that ask this topic