All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · December 2018

The elements 42,25,30,40,22,35,26 are inserted one by one in the given order into a max-heap. The resultant max-heap is stored in an array implementation as

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. <42, 40, 35, 25, 22,30,26 >

Explanation

Insert 42, 25, 30; 40 goes under 25 and swaps up: 42, 40, 30, 25. Add 22 under 40. 35 goes under 30 and swaps: 42, 40, 35, 25, 22, 30. 26 sits under 35. Result ⟨42, 40, 35, 25, 22, 30, 26⟩.

More Data Structures and Algorithms questions