Types of Queue in C
What are the different types of Queue?
There are four different types of Queue in C programming language each one has its own application. There different types of queue are:-
- Simple Queue
- Circular Queue
- Priority Queue
- Double Ended Queue
In this article, we will look at each type and learn where we can use them.
What are the different types of queue?
A simple queue are the general queue that we use on perform insertion and deletion on FIFO basis i.e. the new element is inserted at the rear of the queue and an element is deleted from the front of the queue.
Applications of Simple Queue
The applications of simple queue are:-
- CPU scheduling
- Disk Scheduling
- Synchronization between two process.
Circular queue is a type of queue in which all nodes are treated as circular such that the first node follows the last node. It is also called ring buffer. In this type of queue operations are performed on first in first out basis i.e the element that has inserted first will be one that will be deleted first.
Applications of Circular Queue
The applications of circular queue are:-
- CPU scheduling
- Memory management
- Traffic Management
Priority Queue is a special type of queue in which elements are treated according to their priority. Insertion of an element take place at the rear of the queue but the deletion or removal of an element take place according to the priority of the element. Element with the highest priority is removed first and element with the lowest priority is removed last.
Applications of Priority Queue
The applications of priority queue are:-
- Dijkstra’s shortest path algorithm
- Data compression in huffman codes.
- Load balancing and interrupt handling in operating system.
- Sorting heap.
Double Ended Queue
Double ended queue are also known as deque. In this type of queue insertion and deletion of an element can take place at both the ends. Further deque is divided into two types:-
- Input Restricted Deque :- In this, input is blocked at a single end but allows deletion at both the ends.
- Output Restricted Deque :- In this, output is blocked at a single end but allows insertion at both the ends.
Applications of Double Ended Queue
The applications of double ended queue are:-
- To execute undo and redo operation.
- For implementing stacks.
- Storing the history of web browsers.