0% found this document useful (0 votes)
10 views15 pages

Queue

Uploaded by

Shobhit Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views15 pages

Queue

Uploaded by

Shobhit Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Data Structures

RCS405

-Amit Kumar Tiwari

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.

Number of pointers used One Two (In simple queue case)


Operations performed Push and Pop Enqueue and dequeue
Examination of empty condition Top == -1 Front == -1 || Front == Rear + 1
Examination of full condition Top == Max - 1 Rear == Max - 1

Variants It does not have variants. It has variants like circular


queue, priority queue, doubly
ended queue.
Implementation Simpler Comparatively complex

15

You might also like