The aim of this project is to implement and demonstrate the working of a Queue data structure in C++ by performing the fundamental operations:
- Enqueue (Insertion)
- Dequeue (Deletion)
- Peek (Accessing the front element)
- Display (Traversing all elements)
The project helps in understanding how data is managed in a FIFO (First In – First Out) manner and its importance in solving real-world problems like scheduling, buffering, and resource management.
A Queue is a linear data structure that follows the FIFO (First In, First Out) principle. The element inserted first is removed first.
It has two pointers:
- Front → Points to the element to be removed next.
- Rear → Points to the position where the new element will be inserted.
CHARACTERISTICS:
- Insertion is done at the rear end.
- Deletion is done from the front end.
- Can be implemented using arrays, linked lists, or STL in C++.
TYPES OF QUEUE:
- Simple Queue – Basic FIFO queue.
- Circular Queue – Connects rear to front to avoid wasted space.
- Priority Queue – Elements removed based on priority.
- Double-Ended Queue (Deque) – Insertion and deletion allowed at both ends.
APPLICATIONS:
- CPU and process scheduling in operating systems.
- Managing print jobs in printers.
- Packet switching in networking.
- Customer service systems and ticket counters.
- Traffic and resource management.
ADVANTAGES:
- Simple and efficient for sequential processing.
- Useful in real-world problems requiring orderly execution.
- Forms the basis of advanced structures like priority queues and deques.
LIMITATIONS:
- Fixed size in array implementation may cause overflow or unused memory.
- Searching elements is inefficient since traversal is needed.
- Linked list implementation uses extra memory for pointers.
ENQUEUE (Insert)
- Check if the queue is full. If yes, display "Overflow".
- Increment rear = rear + 1.
- Insert the element at queue[rear].
DEQUEUE (Delete)
- Check if the queue is empty. If yes, display "Underflow".
- Retrieve the element at queue[front].
- Increment front = front + 1.
PEEK (Front Element)
- If the queue is empty, display "Queue Empty".
- Otherwise, return queue[front].
DISPLAY
- Check if the queue is empty.
- If not empty, traverse from front to rear and print all elements.
- The queue follows the FIFO principle, ensuring orderly execution.
- Implementation of enqueue and dequeue operations helps in understanding sequential data management.
- Queues are widely applicable in CPU scheduling, job handling, printers, and communication systems.
- They are simple to implement yet form the basis for priority queues, circular queues, and deques.
- Learning queue implementation in C++ strengthens knowledge of arrays, pointers, and dynamic memory handling.