Stack Visualizer



Stack

A stack is a linear data structure that follows the LIFO (Last In, First Out) principle. This means that the last element added is the first one to be removed.

Basic Operations of Stack

Push (Insertion)

- Adds an element to the top of the stack.
- If the stack is full, it causes stack overflow.

Pop (Deletion)

- Removes the top element of the stack.
- If the stack is empty, it causes stack underflow.

Stack Overflow & Underflow

Stack Overflow

- Happens when you try to push an element into a full stack.
- Example: In a fixed-size array implementation, adding beyond its limit.

Stack Underflow

- Happens when you try to pop an element from an empty stack.
- Example: Trying to remove an element from an empty stack.

Operations Performed