Queues (ADTs)
This addresses M1S02,3 of the CS Unit 2 syllabus
Edu Level: Unit2
Date: Aug 6 2026 - 8:48 PM
โฑ๏ธRead Time:
QUEUES
QUEUES
- A queue is a linear data structure similar to a line in a store
- Follows FIFO (First In First Out)
- New elements are inserted at the rear
- Elements are removed from the front
- Both ends are used โ front for deletion and rear for insertion
ย
FEATURES OF QUEUE
- Linear structure
- Operates on FIFO principle
- Maintains two pointers: front โ points to first element, rear โ points to last element
- Overflow occurs when queue is full
- Underflow occurs when queue is empty
ย
TYPES OF QUEUES
- Simple Queue โ standard FIFO structure
- Circular Queue โ connects rear to front to reuse empty space
- Priority Queue โ elements served by priority rather than order
IMPLEMENTATION
- Can be implemented using arrays or linked lists
- Array implementation uses static memory
- Linked list implementation uses dynamic memory
- Head pointer (front) marks the start of the queue
- Tail pointer (rear) marks the end of the queue
ย
BASIC OPERATIONS
enqueue()โ adds (stores) an item at the reardequeue()โ removes (accesses) an item from the frontpeek()โ returns the front element without removing itisFull()โ checks if queue is fullisEmpty()โ checks if queue is empty
ย
ENQUEUE PROCESS
- Check if queue is full
- If full โ return Overflow
- If not full โ increment rear pointer
- Insert data at position pointed to by rear
- Return success
ย
DEQUEUE PROCESS
- Check if queue is empty
- If empty โ return Underflow
- If not empty โ access data at front
- Increment front pointer to next position
- Return success
ย
DECLARATION VARIABLES
queue[MAX]โ defines maximum capacityfrontโ index of first elementrearโ index of last elementMAXโ constant for queue size
ย
CHARACTERISTICS
- Insertion always occurs at rear
- Deletion always occurs at front
- Traversal happens from front to rear
- Queue size is limited in static implementation
ย
ADVANTAGES
- Maintains order of processing
- Useful for scheduling and buffering
ย
DISADVANTAGES
- Static queues waste memory after repeated insertions and deletions
- Access limited to front and rear
If you are still unsure about how queues work, please watch these videos:
Remember all notes are more accurate to the CAPE syllabus than videos