This question already has answers here:
What are the complexity guarantees of the standard containers?
(3个答案)
在4个月前关闭。
C++ STL中
(3个答案)
在4个月前关闭。
C++ STL中
push_back
提供的标准队列操作(例如pop_front
和std::queue
)的时间复杂度是多少?文档中未提及。 最佳答案
C++ STL中push()
提供的push_back()
(内部在底层容器上调用pop()
)和pop_front()
(内部在底层容器上调用std::queue
)都具有恒定的O(1)
时间复杂度,因为它们仅插入队列末尾或从前端弹出它的。您可以检查http://www.cplusplus.com/reference/queue/queue/以了解有关其他方法及其时间复杂性的更多信息。
关于c++ - C++中队列的时间复杂度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63179545/
10-09 02:51