Table of Contents
A Queue is linear data structure that stores data in a specific order. Insertion in a queue happens at rear-end and deletion at the front-end of the queue. It follows First In, First Out ( FIFO ) principle which means the first element is the one that gets deleted first , because all other elements are added at the rear-end of the queue.
Key Characteristics of Queues
- Linear data structures.
- The order of insertion and deletion is specific.
- Restriction in accessing elements of queue, insertion is at rear and deletion from front.
- Random access to any element in the queue is not possible.
Why Queues are Useful Structures
Queues are useful when you want tasks to complete in an orderly and predictable manner.
- It organize task processing in sequential manner.
- Fair resource allocation because resources like CPU, Memory, Printer, etc., are assigned in order so that no newer process can jump ahead. The resource allocation is predictable.
- Algorithms like Breadth First Search (BFS) use queue structures.
- Queue is used in OS CPU scheduling, control the flow of data packets in networking, and more.
When to Use a Queue
A queue is useful data structures to use when tasks must be processed in the same order they arrive. In other words, if you need to handle tasks in a fair , predictable and sequential order , a queue is the best choice. A queue is frequently used in following scenarios:
- CPU Scheduling
- Disk Scheduling
- Breadth-First Search (BFS)
- Simulation of Real-World Systems
- Data Stream Buffering
- Printer Task Scheduling
CPU Scheduling
The CPU Scheduling is part of operating system that decide which process should be assigned to CPU. The main task of CPU Scheduling is to reduce idle time for CPU and no process should starve while waiting for CPU time.
It uses
- Multiple queues to manage processes.
- Scheduling algorithms to increase the efficiency of CPU.
What are the different queues used by CPU scheduling?
- Job Queue – All new processes goes into the job queue.
- Waiting Queue – All processing waiting for some resource like printer, some data, etc., are scheduled in the waiting queue.
- Ready Queue – All processes waiting for CPU time are queued in the ready queue, but allocated according to one of the CPU scheduling algorithms – FCFS, SJF, Round-Robin , Priority Scheduling, SRTF and Multi-level Queue.
Disk Scheduling
The disk scheduling uses a queue to manage all pending I/O requests from processes. When a process makes an I/O request it has three information.
- Track number of the request.
- Type of operations – read/write.
- Process that made the request.
The goal of the disk scheduling is to minimize the seek time and improve the performance. The disk controller can handle only one request at a time. So the entire scheduling process is:
- Collect all pending requests and put them in a queue.
- Use Disk scheduling algorithm to send the next job to the disk controller. The most common disk scheduling algorithms are: FCFS, SSTF, SCAN, LOOK, and C-LOOK.
Breadth-First Search (BFS)
The breadth-first-search uses a FIFO queue to process nodes of a graph for searching the key element. It employs a simple strategy.
- Start with a source node.
- Node visited , enqueue it.
- Dequeue the front of the queue.
- Visit all the neighbors.
- For each neighbor, repeat step 2-4
Simple example
Consider a graph as shown in following figure.

Step1:
Start -> Enqueue (A).
Queue -> [A].
Step2:
Dequeue (A) -> Visit neighbors B,C.
Enqueue (B, C).
Queue -> [B, C]
Step3:
Dequeue (B) -> Visit neighbors D, E.
Enqueue (D, E).
Queue -> [C, D, E]
and continue the process until you have found the search key.

Simulation of a Real World System
The simulation of a real world system is a computer-based model. It imitates the behavior of the real world system under different conditions. This helps researchers to study the performance, make predictions, and make decisions without affecting the real world system.
Some Examples of Simulation
- Simulating a bank to understand, how many counters required to reduce the wait time. This model use to study – customer arrivals, service time required, and number of tellers.
- Flight simulator is used to train pilot for difficult situations like engine failure during flight.
- Weather simulator that can predict the path of a hurricane.
- Traffic Simulator that can evaluate the effect of a flyover at a busy junction.
Types of Queues
- Linear Queue
- Circular Queue
- Priority Queue
- Deque
- Circular Deque
- Double-Ended Priority Queue
- Multiple-Queues

Frequently Asked Questions (FAQs)
A Queue is a linear data structure that follows the FIFO (First In, First Out) principle. The element inserted first is removed first, just like people waiting in a line.
FIFO means First In, First Out. It describes how elements are processed in a Queue: the first element added is the first one removed.
The main operations are:
– Enqueue → Insert an element
– Dequeue → Remove an element
– Peek → View the first element
– IsEmpty / IsFull → Check Queue status
Common types include:
– Simple Queue
– Circular Queue
– Priority Queue
– Double-Ended Queue (Deque)
– Examples include:
– People waiting in a line
– Print queue
– CPU scheduling
– Ticket booking systems
These all follow FIFO order.
Queues can be implemented using arrays, linked lists, or the queue library provided by languages like Java and Python.