0

我想知道是否有一种方法可以构建支持恒定时间 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)和斐波那契堆,但它们没有t 似乎满足这些要求。

4

1 回答 1

5

This is impossible if priorities can be compared only. The problem is that a constant-time merge can be used to simulate insert in constant time, which, since delete-min also is constant-time, violates the known lower bound on sorting.

于 2015-03-02T15:13:18.860 回答