Foundations‎ > ‎Algorithms‎ > ‎Sorting‎ > ‎

Bubble sort

- Time Complexity -

O(n2)

- Pseudocode -

BUBBLE-SORT(A) 1 do 2 swapped ← false 3 for i ← 0 to length[A] - 1 4 if A[i] > A[i + 1] then 5 swap(A[i], A[i + 1]) 6 swapped ← true 7 while swapped