KEMBAR78
Circular Queue | PDF
0% found this document useful (0 votes)
14 views11 pages

Circular Queue

The document explains the concept of a Circular Queue, which operates on the FIFO principle but connects the last position to the first, creating a circular structure. It details the operations of the Circular Queue, including enQueue and deQueue, and provides pseudocode for these operations. The document emphasizes the conditions for checking if the queue is full or empty during these operations.

Uploaded by

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

Circular Queue

The document explains the concept of a Circular Queue, which operates on the FIFO principle but connects the last position to the first, creating a circular structure. It details the operations of the Circular Queue, including enQueue and deQueue, and provides pseudocode for these operations. The document emphasizes the conditions for checking if the queue is full or empty during these operations.

Uploaded by

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

CIRCULAR QUEUE

BY:
M.SARANYA,AP/CSE
The Circular Queue is similar to a Linear Queue in the
sense that it follows the FIFO (First In First Out) principle but
differs in the fact that the last position is connected to the first
position, replicating a circle.
OPERATIONS :
Front - Used to get the starting element of the Circular Queue.
Rear - Used to get the end element of the Circular Queue.
enQueue(value) - Used to insert a new value in the Circular Queue.
This operation takes place from the end of the Queue.
deQueue() - Used to delete a value from the Circular Queue. This
operation takes place from the front of the Queue.
Enqueue(x) Operation

Check if the queue is full (Rear + 1 % Maxsize = Front)

If the queue is full, there will be an Overflow error

Check if the queue is empty, and set both Front and Rear to 0

If Rear = Maxsize - 1 & Front != 0 (rear pointer is at the end of the


queue and front is not at 0th index), then set Rear = 0

Otherwise, set Rear = (Rear + 1) % Maxsize

Insert the element into the queue (Queue[Rear] = x)

Exit
Enqueue(x) Operation
viod enqueue(int X,circularqueue CQ)
{
if front==(rear+1)% arraysize
printf(“Queue is full”); {
elseif(rear==-1) rear=(rear+1)%arraysize;
{ CQ[rear]=X;
front=front+1; }
rear=rear+1; }
CQ[rear]=X;
}
else
dequeue
dequeue(x) Operation
viod dequeue(int X,circularqueue CQ)
{
if front==-1
printf(“Queue is empty”); {
elseif(front==rear) X=CQ[front];
{ front=(front+1)%arraysize;
X=CQ[front];
front=-1; }
rear=-1; }
}
else
Thank You

You might also like