Which sorting algorithm has the best time complexity in the worst-case scenario?

  • Bubble sort
  • Merge sort
  • Quick sort
  • Insertion sort
Merge sort has the best time complexity in the worst-case scenario among the given options. It has a time complexity of O(n log n) in all cases, making it efficient for large datasets. Quick sort can have a worst-case time complexity of O(n^2) in certain scenarios, making it less preferable for worst-case scenarios compared to merge sort.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *