- GATE CS
- 2026–27 pattern practice
- Algorithms
- Dynamic programming
- Medium
How many structurally different binary search trees can be built with 4 distinct keys?
Algorithm Design
Pick an option to check your answer.
Answer: C. Solution
The count is the Catalan number .
With root , the left subtree has keys and the right has , so .
, , , , and .
Why not the others
- counts the orderings of 4 keys (); different insertion orders can give the same BST.
- is , which has no link to BST shapes.
- drops some shapes; the recurrence gives 14.