Photo AI
Last Updated Sep 27, 2025
Revision notes with simplified explanations to understand Queues quickly and effectively.
256+ students studying
A queue is a linear data structure that stores data in a First-In, First-Out (FIFO) order. This means the first item added to the queue is the first one to be removed. Queues are commonly used in scenarios where order matters, such as task scheduling, managing print jobs, or simulating real-world lines.
A queue supports two primary operations:
Pseudocode Example:
# Simple Queue using a fixed-size array
MAX_SIZE = 10
queue = [None] * MAX_SIZE
front = 0
rear = -1
size = 0
def enqueue(element):
global rear, size
if size == MAX_SIZE:
print("Queue Overflow")
return
rear = (rear + 1) % MAX_SIZE # Circular increment
queue[rear] = element
size += 1
def dequeue():
global front, size
if size == 0:
print("Queue Underflow")
return None
element = queue[front]
front = (front + 1) % MAX_SIZE # Circular increment
size -= 1
return element
In a linked list implementation:
Example in Python:
class Queue:
def __init__(self):
self.items = []
def enqueue(self, item):
self.items.append(item)
def dequeue(self):
if self.is_empty():
return "Queue Underflow"
return self.items.pop(0)
def peek(self):
if self.is_empty():
return None
return self.items[0]
def is_empty(self):
return len(self.items) == 0
Using a Queue to Simulate a Print Queue:
def simulate_print_queue(documents):
queue = Queue()
for doc in documents:
queue.enqueue(doc)
while not queue.is_empty():
print(f"Printing: {queue.dequeue()}")
Circular Queue Implementation:
class CircularQueue:
def __init__(self, capacity):
self.queue = [None] * capacity
self.front = 0
self.rear = -1
self.size = 0
self.capacity = capacity
def enqueue(self, item):
if self.size == self.capacity:
return "Queue Overflow"
self.rear = (self.rear + 1) % self.capacity
self.queue[self.rear] = item
self.size += 1
def dequeue(self):
if self.size == 0:
return "Queue Underflow"
item = self.queue[self.front]
self.front = (self.front + 1) % self.capacity
self.size -= 1
return item
Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!
90 flashcards
Flashcards on Queues
Revise key concepts with interactive flashcards.
Try Computer Science Flashcards9 quizzes
Quizzes on Queues
Test your knowledge with fun and engaging quizzes.
Try Computer Science Quizzes29 questions
Exam questions on Queues
Boost your confidence with real exam questions.
Try Computer Science Questions27 exams created
Exam Builder on Queues
Create custom exams across topics for better practice!
Try Computer Science exam builder12 papers
Past Papers on Queues
Practice past papers to reinforce exam experience.
Try Computer Science Past PapersDiscover More Revision Notes Related to Queues to Deepen Your Understanding and Improve Your Mastery
Join 500,000+ A-Level students using SimpleStudy...
Join Thousands of A-Level Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!
Report Improved Results
Recommend to friends
Students Supported
Questions answered