Back to Academy
stacks queues
Queue
A Queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. Elements are added at the rear and removed from the front. Think of it like a line at a checkout - the first person in line is served first.
Use Cases
- •Task scheduling and job queues
- •Breadth-first search (BFS)
- •Print spooling and request handling
Complexity Analysis
| Metric | Best | Average | Worst |
|---|---|---|---|
| Time | O(1) | O(1) | O(1) |
| Space | O(n) | ||
Visualization
frontrear
Implementation
Output
Click "Run Code" to see output...