O(n) examination of sort algorithm : bubbleSort[ {3,2,2,1} ]
The number of times through the inner loop with n elements is (n-1) + (n-2) + (n-3) ... + 1
So we see that the bubble sort is . This algorithm is almost never used - the QuickSort, for comparison, is O(n log(n)).
Created by Mathematica (September 29, 2004)