Question 70Asked in DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2

Consider a max heap, represented by the array 400, 300, 200, 100, 150, 160, 170, 80, 40. Which will be the new heap after insertion of 350?

  1. A400, 300, 200, 100, 150, 160, 170, 80, 40, 350
  2. B400, 350, 200, 100, 300, 160, 170, 80, 40, 150
  3. C400, 300, 200, 100, 350, 160, 170, 80, 40, 150
  4. D400, 350, 200, 100, 150, 160, 170, 80, 40, 300
Show answerHide answer

Correct answer: (B) 400, 350, 200, 100, 300, 160, 170, 80, 40, 150

Explanation

Insert 350 at the end (position 10). Its parent 150 is smaller, so swap. The new parent 300 is smaller, so swap again. 400 is larger, so stop: 400, 350, 200, 100, 300, 160, 170, 80, 40, 150.

From DSSSB TGT Computer Science PYQ (Technical), 7 Aug 2021, Shift 2

This is question 70 of DSSSB TGT Computer Science PYQ (Technical), 7 Aug 2021, Shift 2. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.