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

Algorithm, Ask question #MWhich of the following is not a characteristic of...

Ask question #MWhich of the following is not a characteristic of good algorithm? inimum 100 words accepted#

Write algorithm for post-order traversal, P os t - o r d e r T ...

P os t - o r d e r T r av er sal :  This can be done by both iteratively and recursively. The iterative solution would require a modification or alteration of the in-

Progrrame, how to write a code for for a company , for calculate the salary...

how to write a code for for a company , for calculate the salary pay

Data structure, Ask question #Minimum 1Mark each of the following statement...

Ask question #Minimum 1Mark each of the following statements as valid or invalid. If a statement is invalid, explain why. a. current ¼ list; b. temp->link->link ¼ NULL; c. trail->l

Entity relationship diagram, This question is based on the requirements of ...

This question is based on the requirements of a system to record band bookings at gigs. (A 'gig' is an event at which one or more bands are booked to play). You do not need to know

Darw a flowchart to input 3 numbers, This algorithm inputs 3 numbers, every...

This algorithm inputs 3 numbers, every number goes through successive division by 10 until its value is less than 1. An output is produced which comprise the number input and a val

Order of linear search, a. In worst case the order of linear search is O (n...

a. In worst case the order of linear search is O (n/2) b. Linear search is more competent than Binary search. c. For Binary search, the array must be sorted in ascending orde

Deletion of a node from a binary search tree, The algorithm to delete any n...

The algorithm to delete any node having key from a binary search tree is not simple where as several cases has to be considered. If the node to be deleted contains no sons,

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