Question discussion

The keys 20, 10, 30, 5, 15 are inserted one by one into an initially empty min-heap. What is the array representation of the heap?

978Medium DSSSB TGT Computer Science 0 replies

The keys 20, 10, 30, 5, 15 are inserted one by one into an initially empty min-heap. What is the array representation of the heap?

  • A10 5 30 20 15
  • B5 20 30 10 15
  • C5 10 30 20 15
  • D5 10 15 20 30
Correct answer: C

Explanation

Inserting 5 bubbles it up past 20 and 10 to the root, giving [5, 10, 30, 20, 15]; inserting 15 needs no swap.

Discussion 0

Nobody has replied yet. Start the discussion!