GATE CS 2015, set 1 · Question 37 · Programming and Data Structures · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4.
Now consider that a value 35 is inserted into this heap. After insertion, the new heap is

Array Index123456789
Value4030201015161784
  1. (A) 40, 30, 20, 10, 15, 16, 17, 8, 4, 35
  2. (B) 40, 35, 20, 10, 30, 16, 17, 8, 4, 15
  3. (C) 40, 30, 20, 10, 35, 16, 17, 8, 4, 15
  4. (D) 40, 35, 20, 10, 15, 16, 17, 8, 4, 30
Answer

Answer (B)

Answer from the official GATE CS 2015 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes