The total number of comparisons in bubble sort is
-
o(n)2
-
o(n2)
-
o(2n)
-
None of these
B
Correct answer
Explanation
Bubble sort's worst-case time complexity is O(n²) because it makes n-1 passes, each comparing up to n-1 pairs of adjacent elements. The total comparisons approach (n-1) + (n-2) + ... + 1 = n(n-1)/2, which is O(n²). Option B correctly represents this quadratic complexity.