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?
- A$O(n\log n)$Correct answer
- B$O(\log n)$
- C$O({n}^2)$
- 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.