Bubble sort
Bubble sort Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swapsthem if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm, which is a comparison sort, is named for the way smaller or larger elements "bubble" to the top of the list. Although the algorithm is simple, it is too slow and impractical for most problems even when compared to insertion sort.[2] Bubble sort can be practical if the input is in mostly sorted order with some out-of-order elements nearly in position. Bubble sort has a worst-case and average complexity of О(n2), where n is the number of items being sorted. https://en.wikipedia.org/wiki/Bubble_sort
posted on 2018-09-20 18:02 猪猪🐷 阅读(130) 评论(0) 收藏 举报
浙公网安备 33010602011771号