Discussion
Which of the following sorting algorithms has the best time complexity in the worst case ?
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.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development