Watch different sorting algorithms in action and understand how they work
Repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted.
O(n)O(n²)O(n²)O(1)procedure bubbleSort(A: list) n = length(A) for i = 0 to n-1 do for j = 0 to n-i-1 do if A[j] > A[j+1] then swap(A[j], A[j+1]) end if end for end for end procedure