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.
Loading...
Related Quiz
- Which SDLC model is best suited for large projects with uncertain or evolving requirements?
- Which ACID property ensures that transactions maintain consistency in the database?
- You encounter a situation where a particular feature of your software intermittently fails in production but works fine in the development environment. How would you approach debugging and resolving this issue?
- How can query execution plans help in optimizing database queries?
- Which function is used to output data to the console in JavaScript?