ISRO CS-2023
February 7, 2024ISRO CS-2023
February 7, 2024ISRO CS-2023
Question 6
|
Worst case time complexity of heap sort for n elements
O(nlogn)
|
|
O(logn)
|
|
O(n2)
|
|
O(n)
|
Question 6 Explanation:
Heap Sort has a time complexity of O(n log n) in the worst case because it builds a max-heap or min-heap (depending on whether it’s sorting in ascending or descending order) and performs n iterations (heapify) for n elements.
Each heapify operation takes O(log n) time in the worst case.
Each heapify operation takes O(log n) time in the worst case.
Correct Answer: A
Question 6 Explanation:
Heap Sort has a time complexity of O(n log n) in the worst case because it builds a max-heap or min-heap (depending on whether it’s sorting in ascending or descending order) and performs n iterations (heapify) for n elements.
Each heapify operation takes O(log n) time in the worst case.
Each heapify operation takes O(log n) time in the worst case.
Subscribe
Login
0 Comments