【问题标题】:Priority queue with O(1) Get-Min, Delete-Min and Merge operations具有 O(1) Get-Min、Delete-Min 和 Merge 操作的优先级队列
【发布时间】:2015-03-02 15:10:55
【问题描述】:

我想知道是否有一种方法可以构建支持恒定时间 get-min、delete-min 和合并操作的优先级队列结构。我不关心插入的时间复杂度,它不必支持减少键操作。我在(坏)伪代码中的用例:

func periodical(current_state) {
    // always_executed_jobs is a priority queue
    queue = always_executed_jobs;
    // other_jobs is an array of priority queues;
    // current_state is an index to the array, so
    // sometimes_executed_jobs is another priority queue
    sometimes_executed_jobs = other_jobs[current_state];
    queue.merge(sometimes_executed_jobs);
    while (!queue.empty()) {
        job = get_min(queue);
        execute(job);
        delete_min(queue);
    }
}

我考虑过展开树(特别是 https://cs.stackexchange.com/questions/524/does-there-exist-a-priority-queue-with-o1-extracts)和斐波那契堆,但它们似乎不能满足这些要求。

【问题讨论】:

  • 我认为这不可能。恒定时间合并将允许在 O(n) 中构建包含 n 个元素的队列,使用恒定时间删除分钟将允许在 O(n) 中对元素进行排序。

标签: algorithm heap priority-queue splay-tree


【解决方案1】:

如果只能比较优先级,这是不可能的。问题是常数时间的merge可以用来模拟常数时间的insert,因为delete-min也是常数时间,违反了已知的排序下限。

【讨论】:

  • 很好的推理。既然不可能的前提是只能比较优先级,是否可以通过优先级的其他属性来缓解这个问题?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-02
相关资源
最近更新 更多