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)?

  1. A.

    Heapsort

  2. B.

    Quicksort

  3. C.

    Insertion sort

  4. 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.

Explore the full course: Up Lt Grade Assistant Teacher 2025