Stack/QueueStack & Queue
Queue (FIFO)
A first-in, first-out collection: elements enter at the back and leave from the front.
1/12A queue is first-in, first-out: elements enter at the back and leave from the front, so the order of arrival is preserved.
Just enqueuedFrontBeing dequeued
PseudocodeLearn Queue →
1enqueue(x): items.append(x) # at the back2dequeue(): return items.pop_front() # from the front3peek(): return items[front]Variables
size0
Complexity
access O(n)
search O(n)
insert O(1)
delete O(1)
Speed