Multiple choice technology architecture

The complexity of Bubble sort algorithm is

  1. O(n)

  2. O(log n)

  3. O(n2)

  4. O(n log n)

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Bubble sort has O(n²) time complexity because it uses nested loops - the outer loop runs n times and the inner loop runs up to n times in the worst case, giving n×n = n² comparisons.