GATE Computer ScienceVery hardGATE CS · ISRO

How many different arrays of the distinct keys 1, 2, …, 10 are valid max-heaps (complete binary tree, parent larger than both children)?

  1. A. 2360
  2. B. 5040
  3. C. 3360
  4. D. 1360

Correct answer: C. 3360

With H(n) = C(n−1, L) · H(L) · H(n−1−L), where L is the left-subtree size (L = 6 for n = 10), we get H(10) = 3360.

More Algorithms questions

Exams that ask this topic