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

Discussion

What is the time complexity of Merge Sort in the worst case ?

  • A.O(n)
  • B.O(n log n)
  • C.O(n^2)
  • D.O(log n)

Answer: B

Merge sort's worst case is O(n log n).

Merge sort always splits the array in half (about \(\log_2 n\) levels) and merges each level in O(n) time, whatever the input order, so its best, average and worst cases are all \(O(n \log n)\).

\(O(n^2)\) is the worst case of quick sort and simple sorts, O(n) the best case of bubble or insertion sort, and O(log n) binary search.

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

Post your comment

Please log in or register to post a comment.