Skip to content

ISRO Scientist/Engineer CSE 2023Algorithms › Sorting

ISRO Scientist/Engineer CSE 2023 PYQ: Worst case time complexity of heap sort for $n$ elements?

Worst case time complexity of heap sort for $n$ elements?

  1. A
    $O(n\log n)$
    Correct answer
  2. B
    $O(\log n)$
  3. C
    $O({n}^2)$
  4. D
    $O(n)$

Answer

(A) $O(n\log n)$

Approach

Heap sort builds a max-heap from the array and repeatedly extracts the maximum element, restoring the heap property each time. Both the heap construction and each of the n extractions take O(log n) time, giving a total worst-case complexity of O(n log n).

Reviewed by ISRO IQ Editorial Team.