A sorting algorithm is called STABLE if
Ait never crashes on adversarial inputs
Bthe order of equal-keyed elements is preserved
Cit runs in the same time on every input of size n
Dit only sorts numeric data, never strings
Answer & Solution
Correct answer: B. the order of equal-keyed elements is preserved
Stability is about equal-keyed elements: if Alice and Bob both have score 80 and Alice was earlier in the input, Alice stays before Bob in the sorted output. Merge sort, insertion sort, bubble sort are stable; standard quick sort and heap sort are not. Crash safety, input-independence and data type are unrelated.
Related questions
An NP-hard problem differs from an NP-complete one because NP-hard problemsThe first problem proved to be NP-complete wasA problem X is NP-complete if and only ifWhy does theoretical computer science draw the line at 'polynomial-time' for tractability?Which set inclusion is established (i.e., proven, not open)?The class NP is the set of decision problems for whichFloyd-Warshall detects the presence of a negative cycle byTopological sort is well-defined for