## bubble sort

61 examples (0.02 sec)
• Info Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. more...
• It can achieve slightly better performance than a standard bubble sort.
• The positions of the elements in bubble sort will play a large part in determining its performance.
• Typically cocktail sort is less than two times faster than bubble sort.
• However one cocktail sort pass should be counted as two bubble sort passes.
• It improves upon bubble sort and insertion sort by moving out of order elements more than one position at a time.
• Various efforts have been made to eliminate turtles to improve upon the speed of bubble sort.
• Bubble sort has been occasionally referred to as a "sinking sort".
• Bubble sort should be avoided in the case of large collections.
• Therefore, bubble sort is not a practical sorting algorithm when n is large.
• It is a comparison sort related to bubble sort, with which it shares many characteristics.
• Rabbits, large values around the beginning of the list, do not pose a problem in bubble sort.
• The reason for this is that bubble sort only passes through the list in one direction and therefore can only move items backward one step each iteration.
• Unlike in bubble sort, where the gap is constant i.e. 1.
• Bubble sort the array by comparing adjacent numbers, and swapping them if they are in the wrong order.
• In bubble sort, when any two elements are compared, they always have a gap (distance from each other) of 1.
• Note, however, that cocktail sort more often refers to a bidirectional variant of bubble sort.
• Bubble sort and variants are rarely used in practice, but are commonly found in teaching and theoretical discussions.
• Bubble sort and insertion sort can be interpreted as particular instances of this procedure to put a sequence into order.
• For these reasons many modern algorithm textbooks avoid using the bubble sort algorithm in favor of insertion sort.
• The algorithm differs from a bubble sort in that it sorts in both directions on each pass through the list.