How it works
Stack operations
Push and pop at one end give LIFO order, powering recursion, expression parsing, and depth-first search.
Queue operations
Enqueue at the back and dequeue at the front give FIFO order, powering breadth-first search and buffering.
Variants
A deque allows both ends, and a priority queue orders by key rather than arrival time.