【问题标题】:Heap sort using only insert and remove?仅使用插入和删除进行堆排序?
【发布时间】:2012-04-10 01:50:08
【问题描述】:

我正在对我的算法考试进行复习,这是我在没有示例解决方案的旧考试中发现的一个问题。我不确定这个问题的合理答案是什么:

Using a heap and its two operations Remove and Insert,  design an algorithm which sorts an array of size n in O(nlogn) time.

对我来说,这个问题看起来像一个简单的堆排序问题,我认为我的答案是:
- 1) 将每个元素插入到最小堆中
- 2) 从顶部删除堆中的所有内容并将它们按顺序放入数组中...

不确定这是他们想要的,任何人有任何想法请分享。

【问题讨论】:

    标签: algorithm sorting heap heapsort


    【解决方案1】:

    我认为你在正确的轨道上。请参阅here,幻灯片 39。

    【讨论】:

      猜你喜欢
      • 2016-10-19
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 1970-01-01
      • 2015-01-24
      • 2018-07-10
      • 2011-06-17
      相关资源
      最近更新 更多