跳到主要内容

资源 · 指南或文章

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 swaps them if they are in the wrong order (ascending or descending arrangement). The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.

PrepKit 概览

本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。

适合人群
来源未说明适用级别
形式
参考资料

涵盖内容

  • 遍历与交换的过程,附动画。
  • 复杂度表:最好 n,平均和最坏 n 的平方,内存 1,稳定。

使用建议

这是 PrepKit 的学习建议,并非来源的说法。

编写代码,并在某一轮没有发生交换时提前退出,然后解释为什么这样最好情况为 n。

范围与局限

内容简短;没有代码讲解或练习。链接到维基百科和 YouTube。附有葡萄牙文版本的链接。

获取方式与形式

GitHub 上 trekhleb/javascript-algorithms(MIT)中的英文 README,免费。

PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88

本概览的依据
  • src/algorithms/sorting/bubble-sort/README.md

收录此条目的页面

订阅 PrepKit 通讯

可选。使用 PrepKit 并不需要订阅。

我们如何处理你的邮箱