Circular Queue and Implementation

Circular Queue :

  • In  a standard queue, re-buffering problem occurs for each  dequeue operation. To solve this problem, we join the front and rear ends of a queue to make the queue as a circular queue.
  • In this ,the last node is connected back to the first node to make a  circle.
  • It follows FIFO principle.
  • It can be implemented by either circular linked list or array.
  • In array implementation, FRONT>REAR in circular queue whereas FRONT<REAR(always) in simple queue.
  • In circular list implementation, FRONT=REAR=START & deletion is performed at rear and insertion at front.

Circular Queue 

OVERFLOW : Overflow occurs when the queue is full to it’s maximum size and further insertion can’t be done. Conditions are:

  1. FRONT=0 and REAR=Max
  2. FRONT=REAR+1

UNDERFLOW : Underflow occurs when Queue is having zero elements and a deletion is performed on it. Conditions for underflow are:

  1. REAR=FRONT=-1

Algorithms for Insertion and Deletion in Circular Queue :

INSERTION :

 

Insertion in Circular Queue

DELETION :

Deletion in circular Queue

C SOURCE CODE

Leave a Reply

Your email address will not be published. Required fields are marked *