Stack Data Structure
Stack is a linear data structure that follows a particular order in which the operations are performed. The orders can be LIFO or FILO.
It performs the following operations:
- Push
- Pop
- Peek or Top
- isEmpty
Time complexities in stack operations:
We cannot run loops in Push, Pop, Peek, or Top, and isEmpty, as they all take O(1) time.
Applications of the stack:
- It does prefix/infix conversions.
- It provides redo/undo functions.
- It balances the symbols.
- It is widely used in various algorithms, such as the histogram program.
- It is used as primary management for a running purpose in modern-day computers.
- It does string reversal.
- It does backtracking.
- It is used in graph algorithms.
Implementing stack by using linked list:

ReferenceStack Data Structure