Page 523 - Computer science 868 Class 12
P. 523
Step 6: Accept cont
Step 7: If cont=“Yes” or cont=“yes” then go to Step 3
Step 8: Stop.
The algorithm for deletion operation in a circular queue is given below.
int dequeue(int qu[] , int max , int front , int rear)
Step 1: Start.
Step 2: If rear = front then display “Queue Underflow”, return value
Step 3: Assign t=qu[front]
Step 4: Assign front = (front+1)%max
Step 5: Return t
Step 6: Accept cont
Step 7: If cont=“Yes” or cont=“yes” then go to Step 2
Step 8: Stop.
Program 6 A class called Cqueue is defined to perform operations on a Circular queue. The class
description is given below.
Class name : Cqueue
Data Members
ele[] : an array to hold integer elements
cap : to store the capacity of the array
front : to point to the index of the front
rear : to point to the index of the rear
Member Functions
Cqueue (int max) : constructor to initialise the data members cap=max, front=0,
rear=0 and create the integer array
void enque(int v) : to add integers from the rear index if possible else display the
message “Queue full..overflow”
int deque() : to remove and return element from the front, if array is
empty then return -999
void display() : to display the elements present in the circular queue
Specify the class Cqueue giving details of the constructor(int), member functions void
enque(int), int deque(), and void display().
1 import java.util.*;
2 class Cqueue
3 {
4 int ele[];
5 int cap, front,rear;
6 Cqueue(int max) //constructor
7 {
521
Data Structures 521

