Definition:
An implementation of a bounded queue using an array.
(or)
In circular queue, the insertion of a new element is performed at the very first location of the queue if the last location of the queue is full, in which the first element comes just after the last element.
Advantages :
It overcomes the problem of unutilized space in leaner queues, when it is implemented as arrays.
Insertion :
Rear = (rear+1)%Maxsize
Alogarithm Steps:
Step 1: create and set the variables front,rear,MAXSIZE,cq[]
step 2: Read the circular queue opeartion type.
step 3: If operation type is Insertion below steps are executed.
- Assign rear=rear%MAXSIZE.
- if front equal to (rear+1)%MAXSIZE then display queue is overflow.
- if front equal to -1 then assign front=rear=0.
- Otherwise assign rear=(rear+1)%MAXSIZE and read queue data .
- Assign cq[rear] as data.(i.e. cq[rear]=data).
step 4: If operation type is Deletion below steps are executed.
- Check front=-1 then display queue is underflow.
- Set temp as cq[front] (i.e. temp=ca[front]).
- Check front equal to rear if it is true then assign front=rear=-1(Move the front to begining)
- Assign front=(front+1)%MAXSIZE.
C Program To Implement Circular Queue Using Array
CPP Program To Implement Circular Queue Using Array
|