[英]Deque (time complexity)
What is the time complexity for accessing deque[0], deque[somewhere in the middle], and deque[-1]?访问 deque[0]、deque[中间某处] 和 deque[-1] 的时间复杂度是多少?
From the documentation :从文档中:
Indexed access is O(1) at both ends but slows to O(n) in the middle.
索引访问在两端都是 O(1),但在中间慢到 O(n)。 For fast random access, use lists instead.
对于快速随机访问,请改用列表。
This suggests that the implementation is a doubly-linked list.这表明该实现是一个双向链表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.