The GATE Grind

GATE 2024 CS (CS1) – Question 41

Programming and Data Structures · Binary Heaps · 2 marks · Multiple choice

An array [82, 101, 90, 11, 111, 75, 33, 131, 44, 93] is heapified. Which one of the following options represents the first three elements in the heapified array?

  1. 82, 90, 101
  2. 82, 11, 93
  3. 131, 11, 93
  4. 131, 111, 90

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (D) 131, 111, 90

Explanation

Build-max-heap bottom-up places the maximum 131 at the root. The second level ends up with 111 and 90, so the first three are 131, 111, 90.