• retagged by
3,594 views
1 1 vote

The number of binary search trees possible with 12 keys, when keys 1, 2, 3, 4, ........ 12 are inserted into empty Binary Search Tree with condition such that 4  is the root of binary search tree and 8 is immediate right child of 4 are ________.

3 Answers

5 5 votes
note that given that it is a binary search tree,

root is fixed to 4 and root immediate right child is fixed to 8, therefore

total elements less than 4, should be left side of root ==> there are 3 elements  ( 1, 2, 3) ===> 5 tree structures we can get

 total elements grater than 8, should be right side of node 8 ==> there are 4 elements ( 9,10,11,12 ) ===> 14 tree structures we can get

therefore total elements grater than 4 and less than 8, should be left side of node 8 ==> there are 3 elements ( 5,6,7 ) ===> 5 tree structures we can get.

 

For required a complete Binary Search Tree structure, we have to these three process ===> 5*5*14 = 350 possible structures possible
0 0 votes

///now rest of the element 5,6,7,9,10,11,12 they can also come in order , s0 it becomes = 7! =5040

this line is false as suppose u take 12 after 8 ,then 12 in right of 8 after that u insert 5 then as it insert at leaf 5 <12 and 5 also <8 but it is in right of 8 so false statement

Insertion of a key 
A new key is always inserted at leaf. We start searching a key from root till we hit a leaf node. Once a leaf node is found, the new node is added as a child of the leaf node

same case for 1,2,3,8

see JUST REMEMBER WE ALWAYS INSERT NODES AT LEAF LEVEL NOT UPPER .

so if u inert 8 then 8 is leaf then u r of no good again.

so total ways according to me is  

5 ( for 3nodes total  5 bst ) * 5 * 14 = 350

Position:
Show:

Related questions

0 0 votes
1 1 answer
1.7k
1.7k views
sandeep singh gaur asked Mar 22, 2019
1,662 views
The number of possible ordered trees with 3 nodes A,B,C is ??
12 12 votes
9 answers 9 answers
24.7k
24.7k views
ajit asked Sep 23, 2015
24,691 views
How many different trees are there with four nodes $\text{A, B, C}$ and $\text{D}?$$30$$60$$90$$120$
0 0 votes
1 1 answer
1.4k
1.4k views
Naveen Kumar 3 asked Aug 4, 2018
1,358 views
1. How many Binary trees can be made with:(a) 3 unlabelled nodes?(b) 3 labelled nodes?2. How many Binary Search trees can be made with:(a) 3 unlabelled nodes?(b) 3 labell...
3 3 votes
0 0 answers
2.3k
2.3k views
iarnav asked Jan 7, 2018
2,266 views
Consider a binary tree T that has 150 leaf nodes. Then the number of TOTAL nodes in T that have exactly two children are ______.