1,515 views
2 votes
2 votes
Number of ways we can insert 5,6,9,10 in the nodes of BST, such that height of BST is either 2 or 3?

1 Answer

0 votes
0 votes
I think answer will be 14

We have 5,6,9,10

Now if we take 10 at root then 5 trees will be there 4 with height 3

and 1 with height 2

If we take 10 then for height 3 -4 trees

Similarly for 5 if it is selected to insert at root  node then 5 trees possible

Now if we insert 6 at root node then definitely 5 will be it's left child so 2 trees are possible by arranging 9 and 10 as it's right child

And same will be for 9 also two trees are possible with height 2

H(3)4+H(3)4+H(2)1+H(2)1+H(2)2+H(2)2

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2