1,394 views
0 votes
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
5 votes
5 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

Related questions

0 votes
0 votes
1 answer
1
deepak_8404 asked Oct 1, 2023
280 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 ...
–4 votes
–4 votes
2 answers
3
Souvik33 asked Oct 27, 2022
602 views
*MSQ*The following figure depicts a a. A tree and only treeb. A tree with 3 nodesc. A graph (Since every tree is a graph)d. A graph and only graph
0 votes
0 votes
1 answer
4
Overflow04 asked Sep 28, 2022
436 views
Can we determine unique tree by Inorder and level order traversal .