Queue (Complete Exam Notes)
1. Definition (FIFO)
A queue is a linear data structure that follows FIFO (First In First Out). The element inserted first is removed
first. It works like a real-life line of people — first person in line leaves first.
2. Basic Operations
Enqueue: Insert element at rear.
Dequeue: Remove element from front.
Front: Shows first element.
Rear: Shows last element.
3. Algorithms
Enqueue Algorithm:
1. Check if queue is full
2. If full → overflow
3. Else insert element at rear
4. Move rear pointer forward
Dequeue Algorithm:
1. Check if queue is empty
2. If empty → underflow
3. Remove element from front
4. Move front pointer forward
4. Diagram
Front → 10 20 30 ← Rear
5. Types of Queue (With Explanation)
Simple Queue: Normal queue where insertion is from rear and deletion is from front.
Circular Queue: Last position connects back to first. Saves space and avoids shifting.
Priority Queue: Each element has priority. Higher priority elements are removed first.
Deque (Double Ended Queue): Insertion and deletion allowed from both front and rear.
6. Applications
• CPU scheduling
• Printer queue
• Call center waiting system
• Data buffering
• Breadth First Search (BFS)