跳到主要内容

资源 · 指南或文章

Bucket Sort

桶排序:把值分散到各个桶中,分别排序后再收集起来,并说明其运行时间如何取决于输入分布。

审核日期

打开原站: Bucket Sort (在新标签页中打开原网站)

添加到路线图

把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。

来源内容语言:英语

Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. Then, elements are sorted within each bin: The computational complexity depends on the algorithm used to sort each bucket, the number of buckets to use, and whether the input is uniformly distributed.

PrepKit 概览

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

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

涵盖内容

  • 四步算法:建立桶、分散、各桶排序、收集。
  • 每个桶使用插入排序且所有元素落入同一个桶时,最坏为 O(n^2)。
  • 输入分布较为均匀时,k 个桶的平均复杂度为 O(n + k)。

使用建议

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

针对 [0, 1) 范围内的浮点数实现桶排序,再输入聚集分布的数据,并解释为什么会变慢。

范围与局限

内容简短;插图是图片文件,唯一的参考资料是维基百科。没有练习。

获取方式与形式

英文 README,可在 GitHub 上免费阅读,属于采用 MIT 许可的 trekhleb/javascript-algorithms 项目。

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

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

收录此条目的页面

订阅 PrepKit 通讯

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

我们如何处理你的邮箱