Circular queues and implement circular queues using array, Data Structure & Algorithms

Explain what are circular queues? Write down routines required for inserting and deleting elements from a circular queue implemented using arrays.

         Circular queue: Static queues have a very big disadvantage that once the queue is

FULL, even though we delete or remove few elements from the "front" and relieve some occupied space, even then we are not able to add anymore elements as the "rear" has already reached the Queue's rear most position.

The solution lies in a type of queue in which the moment "rear" reaches its end; the "first" element will automatically become the queue's new "rear". This type of queue is well known as circular queue possessing a structure like this in which, once the Queue is full the "First" element of the Queue becomes the "Rear" most element, if and only if the "Front" of it has moved forward;

Circular Queue using an array:-


This procedure inserts an element item into a queue.

1. If front = 1 and rear = n, or if front = rear

+ 1, then:

Write: overflow, and return

2. [find new value of rear]

If front = NULL , then : [queue initially empty.]

Set front = 1 and rear=1. Else if rear = n, then:

Set rear=1.


Set  rear = rear + 1. [end of structure.]

3. Set queue[rear] = item. [this inserts new


4.Return .


This procedure deletes an element from a queue and assigns it to the variable item.

1.   [queue already empty?] If front = NULL , then:

Write: underflow, and return.

2.   Set item = queue[front].

3.   [find new value of front]

If front = rear , then : [queue has only one element to start].

Set front = NULL and rear = NULL. Else if front = n, then:

Set front=1.


Set  front = front + 1. [end of structure.]

4.   Return .

Posted Date: 7/9/2012 10:06:44 PM | Location : United States

Related Discussions:- Circular queues and implement circular queues using array, Assignment Help, Ask Question on Circular queues and implement circular queues using array, Get Answer, Expert's Help, Circular queues and implement circular queues using array Discussions

Write discussion on Circular queues and implement circular queues using array
Your posts are moderated
Related Questions
In assignment, you have already started the process of designing a database for the Beauty Salon mini-case (enclosed again below), mainly in the phase of conceptual database design

What are the conditions under which sequential search of a list is preferred over binary search?

The best average behaviour is shown by  Quick Sort

an electrical student designed a circuit in which the impedence in one part of a series circuit is 2+j8 ohms and the impedent is another part of the circuit is 4-j60 ohm mm program

Phong Shading Phong shading too is based on interpolation, but instead of interpolating the colour value, it is the normal vector, which is interpolated for each point and a co

basic calculation for algorith.

Give an algorithm to find both the maximum and minimum of 380 distinct numbers that uses at most 568 comparisons.

Data records are stored in some particular sequence e.g., order of arrival value of key field etc. Records of sequential file cannot be randomly accessed i.e., to access the n th

Let a be a well-formed formula. Let c be the number of binary logical operators in a. (Recall that ?, ?, ?, and ? are the binary logical operators). Let s be the number of proposit