Data Structures & AlgorithmsModerateProduct-company MCQ pattern

How many structurally different binary search trees can be built from 4 distinct keys?

  1. A. 14
  2. B. 24
  3. C. 5
  4. D. 16

Correct answer: A. 14

The count is the Catalan number C₄ = C(8, 4)/5 = 14: choose each key as the root and multiply the counts for the left and right subtrees (5 + 2 + 2 + 5). 24 counts insertion orders, and many orders give the same tree.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic