Queue terminology
This page standardizes the words used in queue problems and C implementations: front, rear, enqueue, dequeue, peek, capacity, size, overflow, and underflow. Clear terminology makes coding and debugging easier.
- Core queue terms and what each one means
- How terms map to array-based queue variables
- Overflow and underflow with examples
- Circular queue terms: wrap-around logic
- Common naming choices in C code
1) Core terms
| Term | Meaning | Typical C idea |
|---|---|---|
| Front | Position of the first element to remove next | q[front] is the next dequeue |
| Rear | Position where the newest element is inserted | enqueue updates rear then stores value |
| Enqueue | Add an item at the rear | enqueue(x) |
| Dequeue | Remove item from the front | dequeue() |
| Peek / Front() | Read front item without removing | returns q[front] |
| Size | Number of elements currently in queue | often tracked with count |
| Capacity | Maximum storable elements (fixed array) | constant like MAX or capacity |
2) Visual mental model
Queue with 4 elements in processing order:
front rear ↓ ↓ [ 12 ] [ 27 ] [ 41 ] [ 56 ] dequeue removes from left, enqueue adds to right
Important convention
The front points to the element that will leave next. The rear points to the most recently inserted element (or the next insertion slot, depending on implementation style). Pick one convention and keep it consistent in your code.
3) Error terms: overflow and underflow
- Overflow — trying to enqueue when the queue is full.
- Underflow — trying to dequeue (or peek) when the queue is empty.
In C, both conditions must be checked before accessing array positions. Most queue bugs in beginner code come from missing these guards or from updating indices in the wrong order.
4) Circular queue terminology
In an array queue, indices can hit the end of the array even when there are empty cells at the beginning. A circular queue reuses space by wrapping indices with modulo arithmetic.
- Wrap-around — when
rearorfrontmoves fromcapacity - 1to0. - Full condition (common rule) —
(rear + 1) % capacity == front. - Empty condition — either
front == -1(sentinel style) orsize == 0(count style).
5) Naming used in C programs
Different books and codebases use different names. These are common mappings:
| Concept | Common names |
|---|---|
| Front pointer | front, head |
| Rear pointer | rear, tail |
| Enqueue | enqueue, pushBack, offer |
| Dequeue | dequeue, popFront, poll |
| Peek front | front(), peek() |
Key takeaway
Queue terminology is mostly about where items enter (rear) and where they leave (front). If you track these two ends correctly and guard full/empty states, your queue logic stays reliable.
Next up: Characteristics of Queue (FIFO) · Basic queue operations · Queue using array