Discussion
What is the best-case time complexity for the Bubble Sort algorithm ?
Answer: A
The best-case time of bubble sort is O(n).
With the usual optimisation, bubble sort stops when a pass makes no swaps. If the array is already sorted, the first pass of n - 1 comparisons finds no swaps, so it finishes in linear time.
\(O(n^2)\) is its average and worst case, \(O(n \log n)\) belongs to efficient sorts such as merge sort, and O(log n) is binary search.
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