Which of the following sorting algorithms has the lowest worse-case complexity?
View worked solution
Answer: A
To find the sorting algorithm with the lowest worst-case time complexity, let us analyze the worst-case time complexity of each given option for an input of size :
- Merge Sort: in all cases (best, average, and worst) because it always divides the array into two halves and merges them.
- Bubble Sort: in the worst case (e.g., when the array is sorted in reverse order).
- Quick Sort: in the worst case (e.g., when the pivot consistently partitions the array into highly unbalanced subproblems of size and ).
- Selection Sort: in all cases because it always scans the remaining unsorted elements to find the minimum.
Comparing the worst-case complexities, we have:
Therefore, Merge Sort has the lowest worst-case complexity among the choices.
Free practice · Your answers on this page are not saved.
