← Quiz: Heaps and Heap Sort Internals: all 15 questions
Quiz: Heaps and Heap Sort Internals · Question 3 of 15
What does this print? (code)
What does this print?
import heapq
a = [5, 3, 8, 1]
heapq.heapify(a)
print(a[0], sorted(a) == a)
- A.1 True
- B.1 False
- C.5 False
- D.3 True
Answer & explanation
Correct answer: 1 False
heapify gives [1, 3, 8, 5]: the minimum is at the root, but the array is not sorted.
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 →