Stacks in a nutshell
A stack is a linear data structure that uses the Last-In-First-Out (LIFO) principle. Think of a stack of plates that needs to be washed. You take the first plate from the top (which was the last one to be added) and you wash it. Afterward, you take the next plate from the top and so on. This is exactly what a real-life stack is (for example, a stack of plates, a stack of books, a stack of CDs, and so on).
So, technically speaking, in a stack, the elements are only added (known as the push operation) and removed (known as the pop operation) to/from one end of it (known as the top).
The most common operations that are performed in a stack are as follows: