What is the worst-case time complexity of the Heap sort?

2018

What is the worst-case time complexity of the Heap sort?

  1. A.

    O(n)

  2. B.

    O(n2)

  3. C.

    O(n log n)

  4. D.

    O(n3)

Attempted by 391 students.

Show answer & explanation

Correct answer: C

Heap sort has a worst-case time complexity of O(n log n). This occurs because building the heap takes O(n) and extracting elements takes O(log n) for each of the n elements.

Explore the full course: Up Lt Grade Assistant Teacher 2025