Linear Data StructuresBeginner LevelStudy Time: 15 mins

Standard Queue Data Structure

A Queue is a FIFO (First-In, First-Out) linear structure where items enter at the rear pointer and exit from the front pointer.

Loading visualizer workspace...

Queue FIFO Enqueue & Dequeue Step-by-Step

Sample Input:Empty Queue, Operations: Enqueue(10), Enqueue(20), Dequeue()
Step 1

Enqueue Elements (Enqueue 10, Enqueue 20)

Add items at the rear pointer position. 10 arrives first, 20 arrives second.

Front: 0, Rear: 1 | Queue: [10 (Front), 20 (Rear)]
Elements join at the rear and wait in arrival order.
Step 2

Dequeue Front Element (Dequeue)

Remove and return the element at the front pointer (10) and advance front pointer.

Dequeued Value: 10 | Front: 1, Rear: 1 | Queue: [20 (Front/Rear)]
First item in is the first item served (FIFO).

Real-world analogy: Movie Ticket Line

Enqueue
Dequeue
Front
Hover over items for details

People line up to buy tickets. The first person to arrive is the first person served and leaves the line first.

  • Enqueue= Adds an element to the rear.
  • Dequeue= Removes an element from the front.
  • Front= Inspects the item currently at the front.

Operations explained

Complexity analysis

Scenario Simulator: Dataset Size (N = 500)
Presets:
N = 10N = 10,000
Complexity Curve MapStandard Queue: O(1) Constant Time
Time (t)Size N (500)N = 500O(N²)O(N log N)O(N)O(log N)O(1)Standard Queue D
Time Steps (N=500)

1 step (Constant)

O(1) Constant Time

Space Footprint

O(N) Auxiliary Space

Memory growth rate as N expands.

Performance Rank
Optimal Tier

Relative efficiency rating for large N.

OperationTime ComplexitySpace Complexity
EnqueueO(1)O(1)
DequeueO(1)O(1)
FrontO(1)O(1)

Code implementations

class Queue {
  constructor() { this.items = []; }
  enqueue(elem) { this.items.push(elem); }
  dequeue() { return this.items.shift(); }
}

Real-world applications

Case 01

Task Scheduling

OS process scheduling queues.

Case 02

Printer Spooling

Sequences print job requests.

Case 03

BFS Graph Traversal

Level-order traversal queue buffer.

Interview questions

Topic Knowledge Test & Assessment

10 Questions Assessment

Queue Data Structure Mastery Test

Evaluate your knowledge of FIFO mechanics, Enqueue/Dequeue pointers, ring buffers, and task scheduling.