Queue
Queue
Example
Queue after inserting 25, 30, 51, 60 and 85.
www.vectorindia.org 1
Queue Data Strutures
Operations on a Queue
The following operations are performed on a queue data structure...
1. enQueue(value) - (To insert an element into the queue)
2. deQueue() - (To delete an element from the queue)
3. display() - (To display the elements of the queue)
Queue data structure can be implemented in two ways. They are as follows...
1. Using Array
2. Using Linked List
www.vectorindia.org 2
Queue Data Strutures
www.vectorindia.org 3
Queue Data Strutures
Applications of Queue
Just like Stack, in case of a Queue too, we know exactly, on which position
new element will be added and from where an element will be removed,
hence both these operations requires a single step.
Enqueue: O(1)
Dequeue: O(1)
Size: O(1)
Types of Queue:
1. Simple Queue
2. Circular Queue
3. Priority Queue
Simple Queue
In a simple queue, insertion takes place at the rear and removal occurs at
the front. It strictly follows FIFO rule.
www.vectorindia.org 4
Queue Data Strutures
Circular Queue
In a circular queue, the last element points to the first element making a
circular link.
Priority Queue
A priority queue is a special type of queue in which each element is
associated with a priority and is served according to its priority. If elements
with the same priority occur, they are served according to their order in the
queue.
www.vectorindia.org 5
Queue Data Strutures
Insertion occurs based on the arrival of the values and removal occurs based
on priority.
www.vectorindia.org 6
Queue Data Strutures
Note :
Reference Books : Taken contents and diagrams from various websites.
www.vectorindia.org 7