ExamVeda
Login
Home
This question belongs to Data Structure Sorting Algorithms
Sorting Algorithms
?

Which sorting algorithm has a time complexity of O(n log n) in the worst case and is not stable?

Answer & Solution
Correct Answer: Option B
Heap Sort is a sorting algorithm with a worst-case time complexity of O(n log n). It is not stable because the relative order of equal elements may not be preserved during the sorting process.

Option A: Counting Sort is not correct because it has a time complexity of O(n + k), where k is the range of the input, and it is stable.

Option C: Merge Sort has a worst-case time complexity of O(n log n), but it is a stable sorting algorithm.

Option D: Quick Sort has an average-case time complexity of O(n log n), but its worst-case time complexity is O(n²). It is also not stable.

Therefore, the correct answer is Option B: Heap Sort, as it meets the criteria of O(n log n) in the worst case and is not stable.
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
BeaT Me
BeaT Me 2 years ago
time complexity of quick sort is O(n2)
so its answer should be heap sort
heap sort time complexity is O(nlogn) and it's not stable also