What is the worst-case behavior (number of comparisons) for bubble sort?
2019
What is the worst-case behavior (number of comparisons) for bubble sort?
- A.
O(1)
- B.
O(n log n)
- C.
O(n)
- D.
O(n2)
Attempted by 118 students.
Show answer & explanation
Correct answer: D
Bubble sort compares adjacent elements repeatedly. In the worst case, it makes a quadratic number of comparisons, so the behavior is O(n^2).