in DS edited by
616 views
1 vote
1 vote

The number of distinct min heap are possible with keys 1, 2, 3, 4, 5 are ________.

I know, there are variance of this question for Max heap and even for Min heap, the answer won't change, but I just wanna know if my technique is right or not. 

=============================================================================================

 

 

Since it's a Min heap, the minimum value will be at root. 

This will be the min heap as  

                                 o   -------> root will be chosen in 1 way
                                / \
                               o   o 
                              / \ 
                             o  o

-> Left sub tree will be **4C3*1*2** way as again root will get min value and left and right child can get any value. 

-> Lastly the right sub tree => 1C1 = 1 

Totally - 1*4C3*1*2*1 = 8. Is this approach correct?

in DS edited by
by
616 views

4 Comments

edited by
shouldn't be left sub tree 4C3*1*2?
1
1
Yes, indeed, wrongly typed. It's 4C3*1*2. Then is it correct?
0
0
yes then correct.
0
0
Thanks Gupta Ji! :)
1
1

1 Answer

0 votes
0 votes
4c2*1*1

1 comment

I think wrong answer

 Answer is 8
0
0

Related questions