1,837 views
0 0 votes

 Suppose we have a circular array implementation of a queue, with 9 items in the queue stored at data[7] through data[15]. The CAPACITY is 19. Where does the push member function place the new entry in the array?

Explain via exp.

1 Answer

Best answer
4 4 votes

Its given that, (Let consider the index of Queue is starting from 0).

data[0] to data[6] are empty.

data[7] to data[15] are filled with the elements. 

Capacity is 19. Hence data[16] to data[18] are still empty.

We can easily see that 

Front is poiting to the location = 7

Rear is pointing to the location = 15.

Hence If you enter new element then it will get inserted at Rear pointer

Since Rear < Capacity-1, Hence insertion will be successful. 

Hence New element will get inserted at location 16.

selected by
Position:
Show:

Related questions

5 5 votes
1 1 answer
182
182 views
GO Classes asked Jul 20
182 views
What feature of heaps allows them to be efficiently implemented using a partially filled array?Heaps are binary search trees Heaps are complete binary trees Heaps are ful...
6 6 votes
2 2 answers
210
210 views
GO Classes asked Jul 11
210 views
A complete binary tree is stored in an array using $\mathbf{1}$-based indexing, where the root is stored at index $1$.For a node stored at index $11$, which of the follow...
0 0 votes
0 0 answers
481
481 views
Jeeva Shetty asked Dec 13, 2018
481 views
Which of the following C expressions access the (i, j)th entry of an (mn) matrix strored in column major order?n(i-1)+jm(j-1)+im(n-j)+jn(m-i)+j
0 0 votes
1 1 answer
609
609 views
deepak_8404 asked Oct 1, 2023
609 views
Consider a lower triangular matrix stored in row major order as p[-25 - - + 749][-25 - - - + 749] with base address = 6800, size of each element = 6 byte. Find the value ...