# Differences

This shows you the differences between two versions of the page.

 bubble_sort [2012/09/01 12:21]will created bubble_sort [2015/02/02 08:28] (current) 2014/04/28 22:26 will 2013/05/19 02:06 eeklund 2013/05/19 02:06 eeklund Link cocktail sort, provide warning against production use.2012/10/04 21:59 external edit2012/09/30 18:22 will 2012/09/01 12:21 will created Next revision Previous revision 2014/04/28 22:26 will 2013/05/19 02:06 eeklund 2013/05/19 02:06 eeklund Link cocktail sort, provide warning against production use.2012/10/04 21:59 external edit2012/09/30 18:22 will 2012/09/01 12:21 will created Line 1: Line 1: + ====== Bubble sort ====== + Bubble sort is a simple sorting algorithm that sorts by repeatedly swapping out of order pairs until + there are no more pairs that need swapping. ​ It is very seldom a good choice for production use; it is almost + always better to use an insertion sort for small data or a more complicated sort. A related sort is the [[Cocktail sort]], + which can be considered an optimized bubble sort.  Cocktail sort is also seldom suitable for production use. + + ===== Properties ===== + * Stable + * $O(1)$ space + * $O(n^2)$ comparisons + * Adaptive, $O(n)$ when nearly sorted + [algorithm bubble sort] [algorithm bubble sort]