Practice question · True or false
Sorting stability only matters when the records carry information beyond the key being sorted on.
Hints
- What would two equal keys differ in?
- If the records are identical, order between them is unobservable.
Show the answer
True
Why
True. Stability preserves the relative order of equal keys, which is observable only if those records differ in some other field. It is what makes multi-pass sorting work: sort by name, then stably by department, and equal departments stay in name order. Sorting bare integers, stability is undetectable.
Practise Sorting Strategies
The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Sorting Strategies
- Order the steps of one round of selection sort.
- Stability in a sort, preserving the order of equal elements, sounds like a technicality. When does it become…
- Sort each sorting algorithm by its typical asymptotic cost.
- Comparison-based sorting cannot beat O(n log n), and counting sort runs in O(n). Why is that not a…
- Match each sort to its distinguishing property.