GATE Computer ScienceVery hardGATE CSE · ISRO

How many different arrays A[1..9] that are permutations of {1,…,9} satisfy the min-heap property (A[i] ≥ A[⌊i/2⌋] for every i ≥ 2)?

  1. A. 896
  2. B. 1792
  3. C. 886
  4. D. 448

Correct answer: A. 896

The count is 9!/∏(subtree sizes of the 9-node heap shape) = 362880/(9·5·3·3) = 896, verified by enumerating all 9! arrays: 896.

More Programming and Data Structures (GATE) questions

Exams that ask this topic