4.1.2 Stacks
A stack is a simple data structure where you can only add or remove items from one end, known as the "top". Both insertion and deletion of elements occur at this top end. A stack operates on the Last-In, First-Out (LIFO) principle, meaning that the most recently added element is the first one to be removed.
Figure 4.1: Stack of Books
- Top of the stack
- Books stacked one on another
- Last book placed is the first book removed