Codacoda
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

MetricBestAverageWorst
TimeO(1)O(1)O(1)
SpaceO(n)

Visualization

frontrear
Speed:1x
Empty queueStep 1 / 9

Implementation

Output

Click "Run Code" to see output...