🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Sorting, heapq and bisect: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. What does it mean that Python's sort is stable?
  3. Q3. You sort by name first and then by marks with a second stable sort. Which key decides the final order most?
  4. Q4. After heapq.heapify(a), what is guaranteed?
  5. Q5. What does this print? (code)
  6. Q6. How do you get a max-heap with heapq?
  7. Q7. Why add a counter in (priority, counter, task) tuples?
  8. Q8. What does this print? (code)
  9. Q9. What happens if you call bisect on an unsorted list?
  10. Q10. You need the 5 highest scores from one million numbers. What is the best choice?