我正在尝试理解二进制队列和排序队列之间的区别。我知道排序的优先级队列通过维护排序的向量来实现优先级队列接口。但是二进制队列究竟做了什么?
例如,如果我试图对此进行编码会有什么区别?
//Assumes that all elements in the priority queue are out of order.
// Reorder the data so that the PQ invariant is restored.
//Runtime: O(n log n)
template<typename TYPE, typename COMP_FUNCTOR>
void SortedPQ<TYPE, COMP_FUNCTOR>::updatePriorities() {
//Implementation here
}
//Assumes that all elements in the priority queue are out of order.
// Reorder the data so that the PQ invariant is restored.
//Runtime: O(n)
template<typename TYPE, typename COMP_FUNCTOR>
void BinaryPQ<TYPE, COMP_FUNCTOR>::updatePriorities() {
//Implementation here
}