冒泡排序:一种简单的比较排序算法。它会反复遍历序列,比较相邻元素并在顺序错误时交换它们;较大的元素会在多轮交换中逐步“冒”到序列末端。常用于教学与入门理解排序思想,但在大规模数据上效率较低。
/ˈbʌbəl sɔːrt/
Bubble sort is easy to understand but slow on large lists.
冒泡排序很容易理解,但在大列表上很慢。
After each pass of bubble sort, the largest remaining element “bubbles up” to the end of the array.
在冒泡排序的每一轮遍历后,当前最大的元素会“冒到”数组末尾。
“Bubble”意为“气泡”,在这里是比喻:较大的元素经过一次次交换,像气泡在水中上浮一样逐渐移动到序列的末端;“sort”来自法语 sortir(安排、分类)相关词源,表示“排序/整理”。合起来即“像气泡上浮一样的排序方法”。