Which of the following sorting algorithms has the worst time complexity of n…
2018
Which of the following sorting algorithms has the worst time complexity of n log(n)?
- A.
Heapsort
- B.
Quicksort
- C.
Insertion sort
- D.
Selection sort
Attempted by 204 students.
Show answer & explanation
Correct answer: A
Heapsort guarantees a worst-case time complexity of O(n log n) regardless of the input distribution. In contrast, Quicksort can degrade to O(n^2), while Insertion sort and Selection sort consistently exhibit O(n^2) worst-case performance. Therefore, Heapsort is the correct choice.