Implementation of circular queues, Data Structure & Algorithms

Assignment Help:

One of the main problems with the linear queue is the lack of appropriate utilization of space. Assume that the queue can store 100 elements & the complete queue is full. Thus, it means that the queue is holding 100 elements. In case, some elements at the front are deleted, at the last position the element in the queue continues to be at the similar position and there is no competent way to determine that the queue is not full. In this way, space utilization in the case of linear queues is not competent. This problem is arising because of the representation of the queue.

The substitute representation is to illustrate the queue as circular. In case, we are representing the queue by using arrays, then, a queue along n elements begin from index 0 and ends at n-1.So, obviously , the first element in the queue will be at index 0 and the last element will be at n-1 while all the positions among index 0 & n-1(both inclusive) are filled. Under such situation, front will point to 0 and rear will point to n-1. Though, while a new element is to be inserted and if the rear is pointing to n-1, then, it has to be checked if the position at index 0 is free. If yes, then the element can be inserted to that position & rear can be adjusted accordingly. In this way, the utilization of space is enhanced in the case of a circular queue.

In a circular queue, front will point to one position less to the first element anti-clock wise. Thus, if in the array the first element is at position 4, then the front will point to position 3. While the circular queue is created, then both front & rear point to index 1. Also, we can conclude that the circular queue is empty in case front & rear both point to the same index. Figure  illustrates a circular queue.


Related Discussions:- Implementation of circular queues

Determine about the post conditions assertion, Determine about the Post con...

Determine about the Post conditions assertion A  post condition is an assertion which should be true at completion of an operation. For instance, a post condition of the squ

Pest control program, PART- Pest Control Program Prepare a Pest Contro...

PART- Pest Control Program Prepare a Pest Control Program for the facility that will address the management of Rodents, Insects and Birds. Your Pest Control Program should

Order of the matrix, /* The program accepts matrix like input & prints the ...

/* The program accepts matrix like input & prints the 3-tuple representation of it*/ #include void main() { int a[5][5],rows,columns,i,j; printf("enter the order of

Determine the components of illumination, Determine the Components of Illum...

Determine the Components of Illumination The light reaching the eye when looking at a surface has clearly come from a source (or sources) of illumination and bounced off the su

Time required to delete a node x from a doubly linked list, The time needed...

The time needed to delete a node x from a doubly linked list having n nodes is O (1)

Mcs-021, #questWrite an algorithm for multiplication of two sparse matrices...

#questWrite an algorithm for multiplication of two sparse matrices using Linked Lists.ion..

Tower of hanoi, how do we use 4-discs stack to solve tower of hanoi problem...

how do we use 4-discs stack to solve tower of hanoi problem and write an algorithm to solve it?

Algorithm to sort a given list by quick sort method, Q. Write down an algor...

Q. Write down an algorithm to sort a given list by making use of Quick sort method. Describe the behaviour of Quick sort when input given to us is already sorted.

State hsv colour model, HSV Colour Model Instead of a set of colour pri...

HSV Colour Model Instead of a set of colour primaries, the HSV model uses colour descriptions that have a more intuitive appeal to a user. To give a colour specification, a use

Quick sort, This is the most extensively used internal sorting algorithm. I...

This is the most extensively used internal sorting algorithm. In its fundamental form, it was invented by C.A.R. Hoare in the year of 1960. Its popularity lies in the easiness of i

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd