Queue
Queue
RCS405
1
Queue
A queue is a linear list of elements in which
deletion can take place at one end , called the
front , and insertion can take place only at the
other end , called the rear.
First In First Out
FIFO
2
Queue representation
• Array
• Linked list
3
Queue operation
• Insertion:
• Deletion
Special Condition:
Overflow: if rear=Max then queue is overflow
Underflow: if front=rear=-1 or front>rear then queue
is underflow
One element: if front=rear then queue containing
only one element and queue is not empty.
4
5
6
7
Types of queue
• Circular queue
• Double ended queue (De-queue)
– Input restricted dequeue
– Output restricted dequeue
• Priority queue
8
Circular Queue
• A circular queue is one in which the insertion
of new element is done at the very first
location of the queue if the last location at the
queue is full.
9
10
Delete from circular Queue
11
Double ended queue
• In a dequeue, both insertion and deletion
operation are performed at either end of the
queue.
12
Types of dequeue
• Input restricted dequeue: element can be
inserted at only one end but we can delete the
element from both ends.
• Output restricted dequeue: element can be
deleted at only one end but inserted from
both ends.
13
Priority queue
• A priority queue is a data structure in which
each element has been assign a value called
the priority of the element and an element
can be inserted and deleted on the basis of
their priority.
14
BASIS FOR COMPARISON STACK QUEUE
Working principle LIFO (Last in First out) FIFO (First in First out)
Structure Same end is used to insert and One end is used for insertion,
delete elements. i.e., rear end and another end is
used for deletion of elements,
i.e., front end.
15