← 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?
- A.Yes: every parent is at most each of its children
- B.No, because it is not sorted
- C.No, because 3 > 2
- 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 →