Topic Wise Lesson Plane
Introduction to Queues
A queue is a linear data structure that follows the principle:
FIFO – First In, First Out
Think of a line at a ticket counter
-
The person who comes first is served first
-
New people join at the rear
-
Service happens from the front
Basic Terms
-
Front – Position from where elements are removed
-
Rear – Position where elements are inserted
Basic Operations on Queue
-
Enqueue – Insert an element at the rear
-
Dequeue – Remove an element from the front
-
Peek / Front – View the front element
-
isEmpty – Check if the queue is empty
-
isFull – Check if the queue is full (array implementation)
Simple Example
Enqueue(10)
Enqueue(20)
Enqueue(30)
Queue:
Front → 10 20 30 ← Rear
Dequeue() → removes 10
Queue becomes:
Front → 20 30 ← Rear
Queue Representation
Queues can be implemented using:
-
Arrays
-
Linked Lists
Special types of queues:
-
Circular Queue
-
Priority Queue
-
Deque (Double-ended Queue)
Applications of Queue
Queues are used in many real-life and computer applications:
-
CPU scheduling
-
Printer spooling
-
Breadth First Search (BFS)
-
Call center systems
-
Data buffering (keyboard, network)
Advantages
-
Simple and efficient
-
Maintains order of data
-
Insertion and deletion are O(1) operations
Disadvantages
-
No random access
-
Fixed size problem in array-based queues