Module · Queues

FIFO Queue Visualizer

First-In, First-Out — elements enter at the rear and exit from the front.

FRONTREAR
10
front
20
30
rear

Size: 3/6 · Enqueue: O(1) · Dequeue: O(1)

Queue initialized. Front is left, rear is right (FIFO).

Operation History

  • #1Queue initialized. Front is left, rear is right (FIFO).

Time Complexity

Enqueue

Average
O(1)
Space
O(1)

Dequeue

Average
O(1)
Space
O(n)

Peek

Average
O(1)
Space
O(n)

How It Works

A queue follows FIFO — First-In, First-Out. Elements join at the rear and leave from the front, like a line of people waiting.

Queues model task schedulers, print spoolers, and breadth-first search. Enqueue and dequeue both run in constant time.