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