Skip to content
Official PYQ · 2005

GATE CS 2005 Q35 — Binary Search Trees

Explain with AI

How many distinct binary search trees can be created out of 44 distinct keys?

Choose one option
View worked solution

Answer: B

The number of distinct binary search trees (BSTs) that can be constructed using nn distinct keys is given by the nthn^{\text{th}} Catalan number, CnC_n:

Cn=1n+1(2nn)=(2n)!(n+1)!⋅n!C_n = \frac{1}{n+1} \binom{2n}{n} = \frac{(2n)!}{(n+1)! \cdot n!}

For n=4n = 4 distinct keys, we calculate C4C_4 as follows:

C4=14+1(84)C_4 = \frac{1}{4+1} \binom{8}{4} C4=15×8×7×6×54×3×2×1C_4 = \frac{1}{5} \times \frac{8 \times 7 \times 6 \times 5}{4 \times 3 \times 2 \times 1} C4=15×70=14C_4 = \frac{1}{5} \times 70 = 14

Thus, there are 1414 distinct binary search trees that can be created out of 44 distinct keys.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Binary Search Trees questions