What are the advantages for bubble sort?
Bubble sort has no practical applications other than that it is
often cited as an example of how not to write an algorithm. Insert
sort is the best algorithm for sorting small lists of items and is
often used in conjunction with quick sort to sort larger lists.
Like insert sort, bubble sort is simple to implement and is a
stable sort (equal items remain in the same order they were input).
However, insert sort uses copy or move operations rather than swaps
(which is actually three operations per swap) and is therefore
quicker. The only time a bubble sort will work quicker than insert
sort is when the array is already sorted, which renders the entire
algorithm redundant. A modified algorithm that specifically tests
if an array is sorted or not would be more efficient than a
single-pass bubble sort.