Implementation of EnqueueCQ( ) Operation of a Circular Queue using Linked List
struct CQueue
{
int info;
struct CQueue *next;
}* F, *R;
struct CQueue *temp;
// Insertion Operation in Dynamic Circular Queue
void EnQueueCQ( ) {
int item;
struct CQueue *enqueue;
enqueue= (struct CQueue *)malloc(sizeof(struct CQueue));
if(enqueue == NULL) {
printf(“ !!! OVERFLOW!!! “);
}
else {
printf(“\n Enter item to insert in to the Dynamic CQ:”);
scanf(“%d”, &item);
enqueue -> info = item;
enqueue -> next = enqueue;
if( F== NULL) {
F = R = enqueue;
}
else {
enqueue -> next = F;
R->next= enqueue;
R = enqueue;
}
printf(“\n %d is inserted into the Dynamic CQ.”, R->info);
}
}
// Deletion Operation in Dynamic Circular Queue
void DeQueueCQ( ) {
if( F==NULL) {
printf(“\n Empty CQueue or UnderFlow !!!);
}
else if( F == R) {
temp = F;
F=R=NULL;
}
else {
temp=F;
R->next = F->next;
F= F-> next;
}
printf(“%d is deleted from the Circular Queue”, item->info);
free(temp);
}
// Implement Display ( ) function of a Circular Queue using Linked List
void displayCQ( )
{
struct CQueue *item;
if(F==NULL)
{
printf(“\n Underflow !!!);
}
else
{
temp=F;
printf(“\n The elements in CQ are:\n”);
while(temp->next != F)
{
printf(“%d=>”, temp->info);
temp=temp->next;
}
}
printf(“%d=>”, temp->info);
}