Five Real-Life Examples of Stack Operations
TIME : 2016-01-07
Five Real-Life Examples of Stack Operations
A stack is a last-in, first-out structure: the last item added is the first one removed. Everyday examples include:
- Bangles worn on the wrist — the last one slipped on is the first one taken off.
- Rings of the same size stacked on a pole — you can only reach the top ring first.
- Sacks of wheat stacked one on top of another — the top sack has to come off before the ones beneath.
- Battery cells loaded into a torch — the last cell inserted is the first you pull out.
- A stack of plates in a cupboard — you take from the top.
In computing, the same logic shows up in recursion, converting decimal numbers to binary, a waiter serving orders one after another, a truck loaded with wooden crates, and converting infix expressions to postfix notation.