• recategorized by
3,308 views
8 8 votes
The number of BST's possible with $6$ nodes numbered $1$,$2$,$3$,$4$,$5$ and $6$ with exactly one leaf node are .......................

OR

The number of BST's possible with $6$ nodes numbered $1$,$2$,$3$,$4$,$5$ and $6$ having a height of $5$ are .................…

( note :- height of a root is 0 )

2 Answers

Best answer
19 19 votes

The ans is 25=32

Here the elements are  1,2,3,4,5,6 and we need only 1 leaf 

1.So let us fix a root node: To fix the root node we have 2 choice either 1 or 6 from  1,2,3,4,5,6

(if we select any non-extreme elements then only 1 leaf is not possible)

Let us say we select 1 as root node 

2.In each and every level we have 2 different option that is to select i,e; either of extreme elements

So in 2nd level we can select 2,3,4,5,6

Let us say we select 6 in 2nd level 

3.We still have 2 option to select in 2,3,4,5

So this is true in all levels except last level since only 1 element is left.

Therefore, total possibilities are : 2 * 2 * 2 * 2 = 24

The same condition is true for 6 as a root

Hence, 24* 2 (1 as root or 6 as root)  =  25

• edited by
7 7 votes

I'm getting 32. But I followed brute force method. 16 rooted on node 1 and 16 rooted on node 6.

• edited by
Position:
Show:

Related questions

4 4 votes
1 1 answer
1.3k
1.3k views
2 2 votes
1 1 answer
1.9k
1.9k views
Shivi rao asked Oct 9, 2017
1,857 views
Consider file system stores records as per binary search tree principles. If the postorder traversal of records is given by 2, 4, 3, 9, 13, 7, 6, 17, 20, 18, 15. The expe...
1 1 vote
1 1 answer
2.1k
2.1k views
Gupta731 asked Jan 6, 2019
2,141 views
AVL tree is created by inserting the keys 2, 6, 1, 5, 3, 4, 7 in the given order (Assume the tree is initially empty). Then the level order traversals of the tree would b...
2 2 votes
1 1 answer
980
980 views
charul asked Jan 23, 2018
980 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 – 5, ...