Tutorials

Queue


Circular Queue


Circular queue allows insertion of new element at the very first location of the queue in case the last location of the queue is full.

New element at first location can only be inserted if the location is empty.

 

A circular queue can be seen as a loop of rope in which both the end are tied together.

A digrammatic view of the circular queue is given below:

                            circular queue by tutorialsinhand.com

 

The circular queue given above can hold maximum of 7 elements.

 

Why circular queue is needed?

We have already seen in previous chapter that linear queue suffers from the problem of unutilized space when element is deleted and inserted.

 

A circular queue uses front and rear just like queue to keep track of the element to be inserted and deleted.

 

Important points

  • In circular queue, front always point to the first element.
  • At front=rear, the circular queue will be empty.
  • Everytime a new element is inserted, rear is incremented by 1 (Rear=Rear+1)
  • Everytime element gets deleted, front is incremented by 1 (Front=Front+1)

Insertion and deletion operation can also be performed on circular queue. We will learn in detail about them in upcoming chapters.

 



Please Share this page
Views : 42
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!