edited by
19,072 views
38 38 votes

How many distinct BSTs can be constructed with $3$ distinct keys?

  1. $4$
  2. $5$
  3. $6$
  4. $9$

4 Answers

Best answer
54 54 votes

For number of distinct BSTs with $n$ nodes we apply the formula

$\dfrac{C(2n,n) }{n+1}$

$n=3$ here, so $C(6,3)=20$

So, $\frac{C(2n,n)}{n+1} =20/4=5$

Answer is $\mathbf{5}$

REF :- https://gatecse.in/number-of-binary-trees-possible-with-n-nodes/

Correct Answer: $B$

edited by
1 1 vote

Option B) 5 is Correct answer

Let's solve this using Catalan number :

$$C_n = \frac{(2n)!}{(n+1)! n!}$$

here n = no. of distinct keys ; n = 3  (given in question)

 

$$C_n = \frac{(2n)!}{(n+1)! n!}$$      $$  = \frac{(2 * 3)!}{(3+1)! 3!}$$

  $$  = \frac{6!}{4! * 3!}$$       $$  = \frac{6 * 5 }{6}$$

 

$$  = 5 $$ 

   

 

                                      

 

 

0 0 votes
We can solve this using the concept of Catalan Number. They given 3 distinct key.

Then, 1/n+1*(2nCn)  , n=3

=1/4*6c3

1/4 *20

=5 (Option B)

Then ans is 5

 

 

 
Answer:
Position:
Show:

Related questions

78 78 votes
4 answers 4 answers
24.0k
24.0k views
Ishrat Jahan asked Oct 29, 2014
24,014 views
A Binary Search Tree (BST) stores values in the range $37$ to $573$. Consider the following sequence of keys.$81, 537, 102, 439, 285, 376, 305$$52, 97, 121, 195, 242, 381...
45 45 votes
3 answers 3 answers
11.0k
11.0k views
Ishrat Jahan asked Oct 29, 2014
10,969 views
A Binary Search Tree (BST) stores values in the range $37$ to $573$. Consider the following sequence of keys.$81, 537, 102, 439, 285, 376, 305$$52, 97, 121, 195, 242, 381...
45 45 votes
4 answers 4 answers
19.5k
19.5k views
Ishrat Jahan asked Oct 27, 2014
19,509 views
Which of the following is TRUE?The cost of searching an AVL tree is $\Theta (\log n)$ but that of a binary search tree is $O(n)$The cost of searching an AVL tree is $\The...
93 93 votes
8 answers 8 answers
25.7k
25.7k views
Ishrat Jahan asked Oct 29, 2014
25,726 views
A binary tree with $n 1$ nodes has $n_1$, $n_2$ and $n_3$ nodes of degree one, two and three respec­tively. The degree of a node is defined as the number of its neighbou...