mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-18 22:40:59 +00:00
deploy
This commit is contained in:
@@ -5526,7 +5526,7 @@
|
||||
</details>
|
||||
<h2 id="813">8.1.3 堆的常见应用<a class="headerlink" href="#813" title="Permanent link">¶</a></h2>
|
||||
<ul>
|
||||
<li><strong>优先队列</strong>:堆通常作为实现优先队列的首选数据结构,其入队和出队操作的时间复杂度均为 <span class="arithmatex">\(O(\log n)\)</span> ,而建队操作为 <span class="arithmatex">\(O(n)\)</span> ,这些操作都非常高效。</li>
|
||||
<li><strong>优先队列</strong>:堆通常作为实现优先队列的首选数据结构,其入队和出队操作的时间复杂度均为 <span class="arithmatex">\(O(\log n)\)</span> ,而建堆操作为 <span class="arithmatex">\(O(n)\)</span> ,这些操作都非常高效。</li>
|
||||
<li><strong>堆排序</strong>:给定一组数据,我们可以用它们建立一个堆,然后不断地执行元素出堆操作,从而得到有序数据。然而,我们通常会使用一种更优雅的方式实现堆排序,详见“堆排序”章节。</li>
|
||||
<li><strong>获取最大的 <span class="arithmatex">\(k\)</span> 个元素</strong>:这是一个经典的算法问题,同时也是一种典型应用,例如选择热度前 10 的新闻作为微博热搜,选取销量前 10 的商品等。</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user