Queue is an important structure for storing and retrieving data and hence is used extensively among all the data structures. Queue, just like any queue (queues for bus or tickets etc.) follows a FIFO mechanism for data retrieval which means the data which gets into the queue first will be the first one to be taken out from it, the second one would be the second to be retrieved and so on.
Types of Queues in Data Structure
As is clear from the name itself, simple queue lets us perform the operations simply. i.e., the insertion and deletions are performed likewise. Insertion occurs at the rear (end) of the queue and deletions are performed at the front (beginning) of the queue list.
All nodes are connected to each other in a sequential manner. The pointer of the first node points to the value of the second and so on.
The first node has no pointer pointing towards it whereas the last node has no pointer pointing out from it.
Unlike the simple queues, in a circular queue each node is connected to the next node in sequence but the last node’s pointer is also connected to the first node’s address. Hence, the last node and the first node also gets connected making a circular link overall.
Priority queue makes data retrieval possible only through a pre determined priority number assigned to the data items.
While the deletion is performed in accordance to priority number (the data item with highest priority is removed first), insertion is performed only in the order.
Doubly Ended Queue (Dequeue)
The doubly ended queue or dequeue allows the insert and delete operations from both ends (front and rear) of the queue.
Queues are an important concept of the data structures and understanding their types is very necessary for working appropriately with them.
Source link https://www.thecrazyprogrammer.com/2019/01/types-of-queues-in-data-structure.html