Computer Science, asked by harirk2001, 11 months ago

advantages of circular queue over linear queue


harirk2001: Advantages of circular queue over linear queue

Answers

Answered by rishavthakur27
0
Suppose that you are implementing your queue in array of some data type of size n.

Now, in case of linear queues once you fill up the entire space with your data, even though you delete some elements, you wont be able to pour in some more data elements as the rear side of your queue has reached the maximum limit upto which it can accomodate your data.

In case of Circular queues once your entire queue is filled. If you delete some data, you'll be able to put in some more data as the rear variable would again start repeating itself, i.e. once the value of your rear variable is n - 1(the upper bound) and you delete some data from the front, that space would be considered as available in circular queues and rear variable will take the next value 0 (after n - 1) and you would be able to store your data from index 0 of the array until the index upto which space is available(typically pointed by front).

Hope it helped.

Similar questions