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

Design a binary tree, (a) Suppose that t is a binary tree of integers (that...

(a) Suppose that t is a binary tree of integers (that is, an object of type BinTree of Int.) in the state shown in Figure 3.   Give the vectors returned by each of the f

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.

Define binary search technique, Binary search technique:-  This techniq...

Binary search technique:-  This technique is applied to an ordered list where elements are arranged either in ascending order or descending order. The array is separated into t

Write a function that performs integer division, Write a function that perf...

Write a function that performs integer division. The function should take the large number in memory location 1 and divide it by the large number in memory location 2 disregarding

Define linked list ?, Linked lists are among the most common and easiest da...

Linked lists are among the most common and easiest data structures. They may be used to implement various other common abstract data types, including queues, stacks, symbolic expre

Write stream analogues of list processing functions, (a) Write (delay ) as...

(a) Write (delay ) as a special form for (lambda () ) and (force ), as discussed in class. (b) Write (stream-cons x y) as a special form, as discussed in class. (c) Write

Define different types of sparse matrix, Q1. Define a sparse matrix. Explai...

Q1. Define a sparse matrix. Explain different types of sparse matrices? Evaluate the method to calculate address of any element a jk of a matrix stored in memory. Q2. A linear

Define data model, Define data model?  A data model is a collection of ...

Define data model?  A data model is a collection of conceptual tools for explaning data, data relationships, data semantics and consistency constraints.

#titlestrings, given the string "Data Structures & , Algorithms", write a p...

given the string "Data Structures & , Algorithms", write a program that uses sequential search to return index of ''&''

Calculate the k-th power and recursive algorithem, 1. The following is a r...

1. The following is a recursive algorithm to calculate the k -th power of 2. Input k a natural number Output kth power of 2 Algorithem: If k =0then return 1 Else return 2* po

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