- Docs
- STL
- Implement
# Stack Overview
A stack is a Last In, First Out (LIFO) linear data structure.
It's used in various algorithms and applications where elements are
processed in a last-in-first-out manner.
# Operations :
1. Push
- Description: Adds an element to the top.
- Syntax: void push(const T& value);
2. Pop
- Description: Removes the top element.
- Syntax: void pop();
3. Top
- Description: Returns a reference to the top element.
- Syntax: T & top();
4. Size
- Description: Returns the number of elements.
- Syntax: size_t size() const ;
5. Empty
- Description: Checks if the stack is empty.
- Syntax: bool empty() const ;
Overflow: Adding to a full stack may lead to data loss or instability.
Underflow: Removing from an empty stack may cause errors or unexpected behavior.