Stack

Domain: Data Structures

🎯 Motivation

When you need last-in-first-out behaviour — undo history, back button, function calls — a stack is the right structure.

📋 Concrete Example

Python list as stack: stack = []; stack.append('a'); stack.append('b'); stack.pop() returns b (last added). Only the top is accessible.

🔗 Analogy

A stack of plates in the cafeteria. You can only take the top plate (last put down) and you can only add a new plate on top. You cannot pull from the bottom.