in DS
6,691 views
4 votes
4 votes

How many different binary search trees can be constructed using six distinct keys?

  1.   256
  2.   128
  3.   132
  4.   264
in DS
6.7k views

3 Comments

The first few Catalan numbers for n=1, 2, ... are 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 

3
3

or we can use formula 2nCn/(n+1)

12C6/7   12*11=132

4
4
0
0

4 Answers

3 votes
3 votes
We use the catalan number Cn = (2n)!/ (n+1)!*n! to find the number of binary search tree with n vertices.

So in this case n = 6,

Hence 12!/7!*6! = 132

3 Comments

edited by
It is same as binary trees with unlabelled nodes.
0
0
@Sukannya

# of BST with 'n' distinct nodes = # of unlabeled binary trees with 'n' nodes  = $\frac{\binom{2n}{n}}{n+1}$
1
1
Ya, @joshi_nitish. It was a typo and my stupid habit of writing wrong ans inspite of knowing the correct ones... :)
0
0
1 vote
1 vote
132 BST trees are possible
0 votes
0 votes
Get the no. of bst's possible with 'n' nodes

                                          2nCn/n+1 (Catalyn no.)
0 votes
0 votes
12C6/6+1

12!/6!*6!*7

=>132

Ans is 132

Related questions