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

Circular Queue

This Document deals with circular queue, priority queue and deque

Uploaded by

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

Circular Queue

This Document deals with circular queue, priority queue and deque

Uploaded by

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

Circular Queue

Dr.M.Praneesh
Professor
Sri Ramakrishna College of Arts & Science
Stack and Queue / Slide 2

Representation of Queue
 There are two ways to represent a queue in
memory
 Using an array
 Using a linked list
Stack and Queue / Slide 3

Representation of a Queue using an array

 One dimensional array Q[1…..N]


 Queue is Empty : FRONT =0, REAR =0
 Queue is Full : REAR =N, FRONT=1
 Queue contains elements > 1
Front < REAR
Number of elements = Rear – Front + 1
Stack and Queue / Slide 4

Representation of a Queue using an list

 Queue is Empty
 FRONT = REAR = HEADER
 HEADER -> RLINK = NULL
 Queue contains at least one element
 HEADER -> RLINK ≠ NULL
Stack and Queue / Slide 5

Types of Queue
Stack and Queue / Slide 6

Circular Queue
 Circular Queue is not a linear structure but
instead of its circular.
Stack and Queue / Slide 7

Circular Queue
Stack and Queue / Slide 8

Insert

Procedure INSERT_CIRCQ(CIRC_Q, FRONT,


REAR, ITEM, n)
REAR = ( REAR + 1) mod n;
IF ( FRONT = REAR) then CIRCQ_FULL;
CIRC_Q [REAR] = ITEM;
End INSERT_CIRCQ
Stack and Queue / Slide 9

Delete

Procedure DELETE_CIRCQ(CIRC_Q, FRONT,


REAR, ITEM, n)
IF ( FRONT = REAR) then CIRCQ_EMPTY;
FRONT = ( FRONT + 1) mod n;
CIRC_Q [REAR] = ITEM;
End INSERT_CIRCQ
Stack and Queue / Slide 10

Priority Queue
 It is a special type of queue in which the
elements are arranged based on the priority.
 It is a special type of queue data structure in
which every element has a priority associated
with it.
 Suppose some elements occur with the same
priority they will be arranged according to the
FIFO principle.
Stack and Queue / Slide 11

Types of Priority Queue


Stack and Queue / Slide 12

Deques
Stack and Queue / Slide 13

Input restricted deque


Stack and Queue / Slide 14

Output restricted deque


Stack and Queue / Slide 15

Thank You……….

You might also like