Which sorting algorithm is guaranteed to have a worst-case time complexity of O(n log n) and is classified as a stable sorting algorithm?

Answer and explanation

Correct answer: A. MergeSort

  1. Step 1: Examine worst-case runtimes and stability of comparison sorting algorithms.
  2. Step 2: MergeSort uses divide-and-conquer to split arrays and merge them in time in all cases (worst, average, best), while preserving the relative order of equal elements (stable).
Answer
MergeSort.
Why not the others: QuickSort has worst case and is unstable; SelectionSort is ; HeapSort is but unstable.

Practise more Algorithms and Python Programming.

Free questions with an explanation for every one, and full timed EmSAT Achieve (UAE) mock tests.