Photo AI
Last Updated Sep 27, 2025
Revision notes with simplified explanations to understand Queues quickly and effectively.
219+ students studying
A queue is a dynamic data structure that follows the First In, First Out (FIFO) principle. This means the first item added to the queue is the first one to be removed. Queues are widely used in various real-world and computational scenarios, such as managing tasks in printers, handling customer service requests, and simulating real-world queues.
A queue can be implemented using a linked list, where each node contains the data and a reference to the next node.
Example Pseudocode for Dynamic Queue:
CLASS Node
DATA value
POINTER next
CLASS Queue
POINTER front
POINTER rear
METHOD Enqueue(value)
NEW_NODE ← Node(value)
IF front IS NULL
front ← NEW_NODE
rear ← NEW_NODE
ELSE
rear.next ← NEW_NODE
rear ← NEW_NODE
METHOD Dequeue()
IF front IS NULL
RETURN "Queue Underflow"
ELSE
value ← front.value
front ← front.next
IF front IS NULL
rear ← NULL
RETURN value
METHOD Peek()
IF front IS NULL
RETURN "Queue is Empty"
ELSE
RETURN front.value
METHOD IsEmpty()
RETURN front IS NULL
A queue can also be implemented using a static array with a fixed size.
Example Pseudocode for Static Queue:
CLASS Queue
ARRAY data[size]
INTEGER front ← 0
INTEGER rear ← -1
INTEGER count ← 0
METHOD Enqueue(value)
IF count = size
RETURN "Queue Overflow"
ELSE
rear ← (rear + 1) MOD size
data[rear] ← value
count ← count + 1
METHOD Dequeue()
IF count = 0
RETURN "Queue Underflow"
ELSE
value ← data[front]
front ← (front + 1) MOD size
count ← count - 1
RETURN value
METHOD Peek()
IF count = 0
RETURN "Queue is Empty"
ELSE
RETURN data[front]
METHOD IsEmpty()
RETURN count = 0
METHOD IsFull()
RETURN count = size
Task Scheduling in a CPU:
front
and rear
indices, especially in circular queues.front
and rear
pointers when the queue becomes empty after dequeuing all elements.Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!
120 flashcards
Flashcards on Queues
Revise key concepts with interactive flashcards.
Try Computer Science Flashcards12 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
96%
114 rated
Algorithms for the Main Data Structures
Searching and Sorting Algorithms
393+ studying
197KViewsJoin 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