Queues —
First in, first out. Always.
Queues power task scheduling, BFS graph traversal, print spoolers, and message systems. The difference between FIFO and LIFO is conceptually simple — but circular queues, sliding windows, and priority queues get tricky fast. Visualization makes the order of operations crystal clear.
What is a Queue?
A queue is a First-In, First-Out (FIFO) data structure. The first element added is the first one removed — just like a real-world queue or line. Elements enter at the back (enqueue) and leave from the front (dequeue). Queues are used in task scheduling, BFS, print spoolers, and message systems.
Why visualization helps
Sliding window and circular queues are common DSA interview problems. LearnBug lets you run your own solution and see exactly how your window moves — or where it gets stuck. Watch two pointers maintain the queue's front and back at every step.
Every queue operation, animated
BFS Using a Queue
BFS is a queue algorithm. Watch nodes enqueue level by level and see exactly why this traversal order emerges from FIFO.
Sliding Window Maximum
Monotonic deque in action. Watch elements enter and leave the deque to maintain the maximum in the current window — all in O(n).
Circular Queue
Fixed-size queue that wraps around. Watch the front and rear pointers cycle through the array and see how modular arithmetic connects them.
Priority Queue (Min Heap)
Not FIFO — highest priority exits first. Watch elements bubble up and trickle down through the heap structure after every insertion and deletion.
Queue Reversal
Reverse a queue using a stack. Watch the interplay between FIFO and LIFO — a great problem for understanding both structures.
Run your queue code on LearnBug
Paste your code. Watch exactly how your elements enter and leave the queue.