Skip to content
Official PYQ · 2007

GATE CS 2007 Q14 — Searching, Sorting, Hashing

Explain with AI

Which of the following sorting algorithms has the lowest worse-case complexity?

Choose one option
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 nn:

  • Merge Sort: Θ(nlog⁡n)\Theta(n \log n) in all cases (best, average, and worst) because it always divides the array into two halves and merges them.
  • Bubble Sort: Θ(n2)\Theta(n^2) in the worst case (e.g., when the array is sorted in reverse order).
  • Quick Sort: Θ(n2)\Theta(n^2) in the worst case (e.g., when the pivot consistently partitions the array into highly unbalanced subproblems of size 00 and n−1n-1).
  • Selection Sort: Θ(n2)\Theta(n^2) in all cases because it always scans the remaining unsorted elements to find the minimum.

Comparing the worst-case complexities, we have:

Θ(nlog⁡n)<Θ(n2)\Theta(n \log n) < \Theta(n^2)

Therefore, Merge Sort has the lowest worst-case complexity among the choices.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Searching, Sorting, Hashing questions