# Queues
## Data Structures — The Codex Coding
**URL:** https://thecodex.expert/coding/data-structures/queues/
**Type:** data-structure | **Confidence:** high | **Last verified:** 2026-06-01

## CANONICAL DEFINITION
A queue is a linear data structure that enforces first-in, first-out (FIFO) access — elements are inserted (enqueued) at the rear and removed (dequeued) from the front — providing O(1) enqueue, dequeue, and peek.

## COMPLEXITY
- enqueue: O(1)
- dequeue: O(1)
- peek: O(1)
- search: O(n)
- space: O(n)

## REQUIRES
data-structures/arrays, data-structures/linked-lists

## ENABLES
algorithms/searching

## COMMONLY CONFUSED WITH
Python list.pop(0) is O(n) — use deque.popleft(); priority queue != FIFO queue; queue (FIFO) vs. stack (LIFO) determines DFS vs. BFS

## SOURCES
- CLRS 4th ed. §10.1 §22.2
- POSIX.1-2017 mq_send
- Python collections.deque docs
- Knuth TAOCP Vol.1 §2.2.1

*The Codex Coding — thecodex.expert/coding/ — Free forever — Mumbai, India*
