🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Heaps and Heap Sort Internals: all 15 questions

Quiz: Heaps and Heap Sort Internals · Question 12 of 15

Is the array [1, 3, 2, 7, 4, 5] a valid min-heap?

Is the array [1, 3, 2, 7, 4, 5] a valid min-heap?

  1. A.Yes: every parent is at most each of its children
  2. B.No, because it is not sorted
  3. C.No, because 3 > 2
  4. D.No, because 7 is larger than its parent 3
Answer & explanation

Correct answer: Yes: every parent is at most each of its children

Check each parent: 1 ≤ 3 and 2; 3 ≤ 7 and 4; 2 ≤ 5. A heap does not need to be sorted, and a larger child is allowed.

Can you get the rest right without peeking?

Take the timed Quiz: Heaps and Heap Sort Internals quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →