# Circular Queue in Data Structure

## Circular Queue:

In a circular queue, when rear or front reaches **MAXSIZE-1** then rear or front will be 0. The increment of rear or front is:

rear=(rear+1) % MAX and front=(front+1) % MAX

### Algorithm for insertion into circular queue:

Algorithm fnCirQInsert(arrCQueue[], Data) { if(boolQfull==TRUE) Queue is full; else { arrCQueue[rear]=Data; rear=(rear+1) % MAXSIZE; boolQempty=FALSE; if(rear==front) boolQfull=TRUE; } } // End of Algorithm

### Algorithm for deletion into circular queue:

Algorithm fnCirQDelete(arrCQueue[]) { if(boolQempty==TRUE) Queue is empty; else { Data=arrCQueue[front]; front=(front+1) % MAXSIZE; boolQfull=FALSE; if(front==rear) boolQempty=TRUE; } }