The GATE Grind

GATE 2018 CS – Question 56

Programming and Data Structures · Binary Heaps · 2 marks · Numerical answer

The number of possible min-heaps containing each value from $\{1,2,3,4,5,6,7\}$ exactly once is ________.

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 80

Explanation

Count heap orderings of the complete binary tree with 7 nodes: $N(7)=\binom{6}{3}N(3)N(3)=20\times2\times2=80$, since $N(3)=2$ and the root is fixed to be 1.