0% found this document useful (0 votes)
9 views1 page

Circular queue Algorithm

Uploaded by

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

Circular queue Algorithm

Uploaded by

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

EX NO : 9 Circular queue Algorithm

step 1:Start the program.


step 2:create an array of a fixed size.
step 3:Use two pointers front and rear, both
initialized to-1.
step 4:Display Menu
1.Enqueue(Insertion)
2.Dequeue(deletion)
3.Display
4.Exit
step 5:Read choice
step 5.1:Get choice 1 call Enqueue()goto step 5
step 5.2:Get choice 2 call Dequeue()goto step 5
step 5.3:Get choice 3 call display()goto step 5
step 5.4:Get choice 4 goto step 6
step 6:stop the program.

Enqueue()
step 1: If (front and rear == -1) otherwise goto step 2
1.1: set both to 0 and Insert element in rear position
step 2: If(rear + 1)%size==front, otherwise goto step 3
2.1: print “the queue is full”.
step 3:Increment the rear pointer using (rear + 1) % max.
step 3.1: Insert element in rear position
Dequeue()
step 1: If (front and rear == -1) otherwise goto step 2
step 1.1:print “the queue is empty”
step 2:If front equals rear otherwise goto step 3
step 2.1set both pointers back to -1.remove front position element
step 3:remove the value at the front position. Increment the front pointer using
(front + 1) % max.
Display()
step 1: If (front==0 and rear == -1) otherwise goto step 2
step 1.1:print “the queue is empty”
step 2: :if (front>rear) otherwise goto step 3
Step 2.1: initialize i=0
Step 2.2 if(i<=rear)otherwise goto step 2.3
Step 2.2.1 print queue[i]
Step 2.2.2 increment i goto step no 2.2
Step 2.3 initialize j=front
Step 2.4 if(j<=max-1)otherwise goto step 2.5
Step 2.4.1 print queue[j]
Step 2.4.2 increment j goto step no 2.4
Step 3: initialize i=front
Step 4 if(i<=rear)otherwise goto step 5
Step 4.1 print queue[i]
Step 4.2 increment i goto step no 4
step 5:End of display() method.

You might also like