Explain the difference between a stack and a queue, and where each shows up in real systems.
Your answer should cover:
- The access discipline of each (LIFO vs FIFO) and their core operations.
- Two real examples where a stack is the natural fit, and why the problem demands LIFO.
- Two real examples where a queue is the natural fit, and why the problem demands FIFO.
- How each can be implemented efficiently (what structure underneath, and what can go wrong naively).