First in line eats first
Queues as Lunch Lines
The analogy
The lunch line is fair: whoever arrived first gets served first, and new people join at the back. Nobody cuts in. That is a queue — add at one end, remove from the other.
Visualizer
The lunch line
step 1 / 12frontemptyback
An empty lunch line. Two ends that do different jobs: you join at the back, you are served at the front.empty
from collections import deque
q = deque()
q.append("Ada") # join the back
q.append("Bo")
q.popleft() # "Ada" — first in, first out
# never use list.pop(0) — that is O(n)Check yourself
Enqueue A, B, C then dequeue. What comes out?