What is the worst-case time complexity of Bubble Sort?

2018

What is the worst-case time complexity of Bubble Sort?

  1. A.

    O(n)

  2. B.

    O(n^2)

  3. C.

    O(n log n)

  4. 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).

Explore the full course: Up Lt Grade Assistant Teacher 2025