ProgrammingHard

Which sort is stable and runs in O(n log n) worst case, suitable for struct arrays that must keep equal-key order?

  1. A. Quicksort as usually written
  2. B. Heapsort
  3. C. Selection sort
  4. D. Merge sort

Correct answer: D. Merge sort

Merge sort is stable and O(n log n) in the worst case. Typical quicksort and heapsort are not stable, and selection sort is quadratic.

More C Programming questions

Exams that ask this topic