GATE CSE
First time here? Checkout the FAQ!
x
+4 votes
120 views
The number of min heap trees are possible with 15 elements such that every leaf node must be greater than all non-leaf nodes of the tree are ________.
asked in DS by Active (1.7k points)  
retagged by | 120 views

2 Answers

+6 votes
Best answer

at first level,there can be only 1..hence only 1 way

at second level,there can be 2 or 3 ,hence 2 ways

at third level,there can be 4,or 5 or 6 or 7 ,hence 4! ways

at fourth level,there can be 8 or 9or 10 or 11 or 12 or 13 or 14 or 15 ,hence 8! ways

so,total number of min heaps are 1*2* 4! * 8! ways . It looks like this ....


But actually, question only asks to handle leaf nodes not internal nodes, hence the numbers 2,3,4,5,6,7 can be arranged any way.

At root, 1 is for sure fixed, but for 2,3,4,5,6,7 , total ways will be 

$C(6,3) * 2! * 1 * 2! * 8! = 3225600 $ ways.


PS: $C(6,3)$ :- Choose any three elements for left $3$ positions and arrange them in $2!$ ways.

Then, right $3$ positions can be permuted in $2!$ ways .

 

answered by Veteran (13.2k points)  
edited by
–1 vote
is it 274560
answered by Junior (541 points)  


Top Users Jun 2017
  1. Bikram

    3704 Points

  2. Arnab Bhadra

    1502 Points

  3. Hemant Parihar

    1502 Points

  4. Niraj Singh 2

    1481 Points

  5. junaid ahmad

    1432 Points

  6. Debashish Deka

    1384 Points

  7. Rupendra Choudhary

    1220 Points

  8. rahul sharma 5

    1220 Points

  9. Arjun

    1158 Points

  10. srestha

    1006 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 26 - Jul 02
  1. Arjun

    198 Points

  2. akankshadewangan24

    152 Points

  3. Debashish Deka

    138 Points

  4. Hira Thakur

    130 Points

  5. Soumya29

    104 Points


23,399 questions
30,111 answers
67,489 comments
28,424 users