What are the scenarios in which an element can be inserted into the circular queue? | Eklavya Online

What are the scenarios in which an element can be inserted into the circular queue?

  • If (rear + 1)%maxsize = front, the queue is full. In that case, overflow occurs and therefore, insertion can not be performed in the queue.
  • If rear != max – 1, the rear will be incremented to the mod(maxsize) and the new value will be inserted at the rear end of the queue.
  • If front != 0 and rear = max – 1, it means that queue is not full therefore, set the value of rear to 0 and insert the new element there.