Queue (ADT) Simulator
Show enqueue, dequeue, front, rear, overflow, and underflow.
Algorithm
Current line is highlighted.
index 0
index 1
index 2
index 3
index 4
index 5
About This Simulation
This queue simulator shows a FIFO queue with enqueue, dequeue, peek and reset, with the front and rear positions marked and a timeline you can play back.
Features
- Enqueue, dequeue, peek and reset operations
- Front and rear positions shown
- Empty slots shown as placeholders
- Overflow and underflow messages
- Timeline playback of every operation
Explanation
A queue is a linear data structure that follows FIFO: the first element added is the first one removed. Elements are added at the rear and removed from the front, like people waiting in a line.
How it works
- Enqueue: if the queue is full, report overflow. Otherwise place the value at the rear and move rear forward.
- Dequeue: if the queue is empty, report underflow. Otherwise remove the value at the front and move front forward.
- Peek: return the value at the front without removing it.
- In a simple array queue, front and rear only move forward, so space freed at the start cannot be reused. A circular queue fixes this.
Why it matters
Queues are used in CPU and printer scheduling, buffering data streams, handling requests in servers and breadth first search. It is a core CSE220 data structure.
Frequently Asked Questions
What is the time complexity of queue operations?
Enqueue, dequeue and peek all take O(1) time in an array or linked-list implementation.
What is the difference between a queue and a stack?
A queue is FIFO (first in, first out) and a stack is LIFO (last in, first out). A queue adds at the rear and removes from the front; a stack adds and removes at the top.
Why is a circular queue better than a linear queue?
In a linear array queue, the slots before the front are wasted after dequeues, so the queue can report full while space remains. A circular queue wraps the rear around to the start with modulo arithmetic and reuses that space.
What are the types of queues?
Common types are the simple (linear) queue, circular queue, priority queue and double-ended queue (deque).
Topics covered
- Queue ADT
- FIFO (First In, First Out)
- Enqueue and Dequeue
- Front and Rear
- Array Implementation of a Queue
Tags
- queue
- enqueue
- dequeue
- fifo
- front
- rear
Related Simulations
Data Structures
B+ Tree
Insert, delete, search in a B+ tree visualiser
Data Structures
Stack (ADT) Simulator
Visualise push, pop, overflow, and underflow operations
Data Structures
Circular Queue (ADT) Simulator
Demonstrate wrap-around movement of front and rear pointers.
Data Structures
Linked List Simulator
Insert, delete and search in a linked list stored in arrays, with the start and free pointers and every pointer change shown step by step.

