What is the worst-case time complexity of Bubble Sort?
2018
What is the worst-case time complexity of Bubble Sort?
- A.
O(n)
- B.
O(n^2)
- C.
O(n log n)
- D.
O(n^3)
Attempted by 312 students.
Show answer & explanation
Correct answer: B
In Bubble Sort, each pass compares adjacent elements and swaps them if needed. In the worst case, such as a reverse-sorted array, it performs comparisons over nested passes, giving quadratic time complexity O(n^2).