GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
173 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 Boss (8.6k points)   | 173 views

2 Answers

0 votes

Suppose consider 15 elements 1,2,3,4,....15.

It is min heap ,level by level elements are stored.Root is at 1st level.

1st level; 1

2nd level: 2,3

3rd level: 4,5,6,7

4th level: 8,9,10,11,12,13,14,15.

In the second level elements are nodes 2,3 occupies 2 ways.no matter because it satisfies the heap property.

In the 3rd level also same nodes are 4,5,6,7 can be arranged in 4! ways.

In the 4th level 8!

SO TOTAL NO OF TREES ARE 1!*2!*4!*8*=1935360

answered by Veteran (10.8k points)  
What about a heap like this:

1st level: 1

2nd level: 2 5

3rd level: 3 4 6 7

4th level: 8 9 10 11 12 13 14 15

This is also valid according to the question but the answer does not account for these type of heaps.
i miss it,but this type of problems construct every min heap tree construction is so difficult.

so i think nearest no of min neaps consideration is better.
0 votes
Ans should be 8!*7! max 8 values will be tere in leaf, there are 8 nodes they can be arrange in any way and 7 in non leaf they can be arrange in any way.
answered by Junior (721 points)  


Top Users May 2017
  1. akash.dinkar12

    3302 Points

  2. pawan kumarln

    1776 Points

  3. Bikram

    1646 Points

  4. sh!va

    1640 Points

  5. Arjun

    1396 Points

  6. Devshree Dubey

    1272 Points

  7. Debashish Deka

    1142 Points

  8. Angkit

    1044 Points

  9. LeenSharma

    1000 Points

  10. Arunav Khare

    754 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 May 22 - 28
  1. Bikram

    732 Points

  2. Arnab Bhadra

    402 Points

  3. pawan kumarln

    402 Points

  4. bharti

    304 Points

  5. LeenSharma

    238 Points


22,823 questions
29,142 answers
65,209 comments
27,666 users