跳到主要内容

资源 · 指南或文章

Heap Sort

把堆排序描述为用堆改进的选择排序:反复取出最大值,不断扩大已排序区域。

审核日期

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

添加到路线图

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

来源内容语言:英语

Heapsort is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort: like that algorithm, it divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element and moving that to the sorted region. The improvement consists of the use of a heap data structure rather than a linear-time search to find the maximum.

PrepKit 概览

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

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

涵盖内容

  • 与选择排序的关系以及堆的作用。
  • 复杂度表:最好、平均和最坏均为 n log(n);内存 1;不稳定。

使用建议

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

编写 heapify 和排序循环,然后大声解释为什么它只用常数额外内存,却不稳定。

范围与局限

非常简短:除动画外,没有建堆步骤或下沉操作的讲解。只有一个维基百科链接。附有葡萄牙文版本的链接。

获取方式与形式

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

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

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

收录此条目的页面

订阅 PrepKit 通讯

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

我们如何处理你的邮箱