coding180 icon

What are the possible scenarios for inserting elements into the circular queue?

Home > Interviews > PHP

robort - 2022-10-03 14:05:01

Scenarios where elements can be inserted into a circular queue are −

  • If (rear + 1)%maxsize = front, then the queue is full. In this case, an overflow occurs, so the insertion cannot be performed in the queue.
  • If rear != max - 1, then rearwill be incremented to mod(maxsize)and the new value will be inserted into the backend of the queue.
  • If front != 0and rear = max - 1, the queue is not full, so set rearthe value of to 0and insert the new element there.


Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel