🎙 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 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)
  1. A.1 True
  2. B.1 False
  3. C.5 False
  4. 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 →