Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following sorting algorithms has the best time complexity in the worst case ?

  • A.Quick Sort
  • B.Merge Sort
  • C.Bubble Sort
  • D.Selection Sort

Answer: B

The best worst-case complexity is Merge Sort.

Merge sort runs in \(O(n \log n)\) even in the worst case, because it always divides the array evenly.

Quick sort averages \(O(n \log n)\) but degrades to \(O(n^2)\) with bad pivots, and bubble sort and selection sort are \(O(n^2)\) in the worst case.

Heap sort also has a worst case of \(O(n \log n)\), but it is not among the options.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.