Stack/QueueStack & Queue
Deque (Double-Ended Queue)
A queue that supports O(1) insertion and removal at both the front and the back.
1/13A deque supports O(1) insertion and removal at both ends, so it can act as a stack, a queue, or both at once.
Just pushedBeing poppedFrontBack
PseudocodeLearn Deque →
1push_front(x): items.insert(0, x)2push_back(x): items.append(x)3pop_front(): return items.pop_front()4pop_back(): return items.pop()Variables
size0
Complexity
access O(1)
search O(n)
insert O(1)
delete O(1)
Speed