A sorting technique is called stable if
View worked solution
Answer: B
A sorting algorithm is defined as stable if it preserves the relative order of equal (non-distinct) elements in the sorted output as they appeared in the original input.
Formally, if two items and have the same key value (i.e., ) and appears before in the input list, then will also appear before in the sorted list.
- Option A: Stability is independent of time complexity. For example, Merge Sort is stable and takes time, while Heap Sort is unstable but also takes time.
- Option B: This is the exact definition of stability.
- Option C: Stability is independent of the design paradigm. Merge Sort (divide-and-conquer) is stable, whereas Quick Sort (also divide-and-conquer) is typically unstable.
- Option D: Stability is independent of space complexity.
Therefore, the correct option is B.
Free practice · Your answers on this page are not saved.
