Queue
A first-in-first-out (FIFO) structure where the first item in comes out first. You add at the rear and remove at the front, and it's the basis of BFS, task queues, and buffering.
01Queue
Explore How It WorksStarting the queue. A first-in-first-out (FIFO) structure where you enqueue at the rear and dequeue at the front.
enqueue(10) · Add 10 at the rear.
enqueue(24) · Add 24 at the rear.
enqueue(37) · Add 37 at the rear.
dequeue() · Mark the frontmost 10 for removal.
10 leaves and 24 becomes the new front. The first value in comes out first.
enqueue(55) · No gap opens up — 55 is added on at the rear.
dequeue() · The front 24 leaves. Values exit in the order they entered — that's FIFO.
02 Understand It Simply
For EveryoneValues go in at one end and come out at the other, so the first one in is the first one out.
Items enter at the rear and leave at the front.
The first item in comes out first (first-in-first-out, FIFO).
- –Printer queues
- –call-center waiting order
- –task processing order
03 Python Implementation
A clean, readable reference implementation of the core logic of Queue.
04 Frequently Asked Questions
FAQWhat is Queue?+
A first-in-first-out (FIFO) structure where the first item in comes out first. You add at the rear and remove at the front, and it's the basis of BFS, task queues, and buffering.
What is the time complexity of Queue?+
The time complexity of Queue is O(1) enqueue/dequeue. Follow the step-by-step visualization to see exactly why.
Where is Queue used?+
Printer queues, call-center waiting order, task processing order.
What's a simple analogy for Queue?+
Values go in at one end and come out at the other, so the first one in is the first one out.
