Back to Academy
stacks queues
Stack
A Stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle. Elements are added and removed from the same end, called the 'top'. Think of it like a stack of plates - you can only add or remove from the top.
Use Cases
- •Function call management (call stack)
- •Undo/redo operations
- •Expression evaluation and syntax parsing
Complexity Analysis
| Metric | Best | Average | Worst |
|---|---|---|---|
| Time | O(1) | O(1) | O(1) |
| Space | O(n) | ||
Visualization
bottom
Implementation
Output
Click "Run Code" to see output...