GATE Computer ScienceModerateGATE CS (PYQ pattern)

A binary min-heap holds 100 distinct keys in A[1..100]. At how many different positions can the SECOND largest key possibly be?

  1. A. 50
  2. B. 52
  3. C. 51
  4. D. 49

Correct answer: C. 51

Every descendant of the second largest key must be larger than it, so its subtree can contain at most one other node (the largest key). That allows the 50 leaves (positions 51–100) and the internal node 50, whose only child is position 100: 51 positions. Brute force on small heaps confirms the subtree-size ≤ 2 rule.

More Algorithms questions

Exams that ask this topic