gpt4 book ai didi

python - 双端队列随机访问在 python 中为 O(n) 而在 C++ 中为 O(1),为什么?

转载 作者:太空狗 更新时间:2023-10-29 18:34:50 25 4
gpt4 key购买 nike

<分区>

C++ deque :

Random access - constant O(1)

python deque :

Indexed access is O(1) at both ends but slows to O(n) in the middle.

如果我没有遗漏任何东西,对于 python 和 C++ 中的双端队列,其他一切都同样快,至少在复杂性方面如此。在某些情况下,有什么可以使 python 的双端队列更好吗?如果没有,他们为什么不直接切换到 C++ 的功能呢?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com