recategorized by
859 views
1 votes
1 votes

recategorized by

2 Answers

Best answer
6 votes
6 votes

We are given 5 nodes 1,2,3,4,5, we have to follow one rule here which is 1 should always be a child of 4(need not be immediate)

Firstly lets find out what is the root node of the tree among given numbers. We can see 1,2 and 3 can never be the root node  because if we make 1 as root (condition violated) and among 2 and 3 if any one of them is root node 1 and 4 will split into two different subtrees(conditon violated) and hence 1 can never become child of 4

Now we are left with 4 and 5 as root node which is possible according to our given condition.

Lets try with 4 as root node

Node 1,2,3 can be arranged in BST manner, no of ways are nothing but Catalan number= $\frac{C(2n,n)}{n+1}= \frac{C(6,3)}{4}= 5$

5 BST's are possible with 4 as root node.

Now we are left with 5 as root node

After 5 next root cannot be 1,2,3, reason is same as discussed above, hence 4 is next root node.

Again the same condition arises no of ways in which 1,2,3 can be arranged in BST =5

No. of BST with 4 as root node=5

No.of BST with 5 as root node=5.

Hence total number of BST possible=10

10 is the correct answer

selected by
Answer:

Related questions

3 votes
3 votes
1 answer
1
iita asked Jan 19, 2017
3,243 views
The number of BST possible with 6 nodes numbered 1, 2, 3, 4, 5 and 6 with exactly one leaf node __________
0 votes
0 votes
1 answer
2
aditi19 asked Oct 1, 2018
623 views
what are the applications of optimal binary search tree?
1 votes
1 votes
0 answers
3
Anjan asked Jan 9, 2018
338 views
Find number of BST's possible with 6 nodes numbered 1,2,3,4,5 and 6 having 6 as root and height of 4 ?please explain in detail ...
3 votes
3 votes
2 answers
4
VS asked Jan 3, 2018
847 views
Consider a Binary Search Tree is created using element 1 to n in following order: 3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, ....., n – 3, n – 4, n �...