GATE Computer ScienceVery hardGATE CS (PYQ pattern)

How many different max-heaps (valid arrays) can be formed using the 10 distinct keys 1 to 10?

  1. A. 3360
  2. B. 1680
  3. C. 3612
  4. D. 800

Correct answer: A. 3360

The shape of a 10-node heap has 6 nodes in the left subtree and 3 in the right. H(n) = C(n-1, l) H(l) H(r) with H(1) = H(2) = 1, H(3) = 2, H(6) = 20: C(9,6) x 20 x 2 = 84 x 40 = 3360.

More Programming and Data Structures (GATE) questions

Exams that ask this topic