Efficiency of the STL priority_queue

前端 未结 6 1188
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 06:11

I have an application (C++) that I think would be well served by an STL priority_queue. The documentation says:

Priority_queue is a cont

6条回答
  •  既然无缘
    2020-11-30 07:02

    top() - O(1) -- as it just returns the element @ front.

    push() -

    • insert into vector - 0(1) amortized
    • push_into_heap - At most, log(n) comparisons. O(logn)

      so push() complexity is -- log(n)

提交回复
热议问题