Introduction
Imagine you have a stack of plates on a table. You can only add or remove the top plate. This problem of managing items in a strict order is solved by a stack in computing.
Think of a stack of books on a desk. You add new books on top and remove books only from the top. You cannot take a book from the middle without removing the ones above it first.
┌─────────┐ │ Top │ ← Newest item (last pushed) ├─────────┤ │ Item 3 │ ├─────────┤ │ Item 2 │ ├─────────┤ │ Item 1 │ └─────────┘ (push adds here, pop removes here)