Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disadvantage of circular queue?

Recently, in an interview I was asked the disadvantage of using circular queue. I couldn't think of any. Searching the internet the only answer I found is that it's difficult to implement than linear queue :). Is there any other disadvantage?

like image 642
Praveen Kumar Avatar asked Feb 16 '13 06:02

Praveen Kumar


People also ask

What is disadvantage of queue and how it is solved using circular queue?

In a linear queue, the traversal through the queue is possible only once,i.e.,once an element is deleted, we cannot insert another element in its position. This disadvantage of a linear queue is overcome by a circular queue, thus saving memory.

Which limitation is overcome in a circular queue?

Efficient utilization of memory: In the circular queue, there is no wastage of memory as it uses the unoccupied space, and memory is used properly in a valuable and effective manner as compared to a linear queue.

What is the limitation or disadvantage of simple queue?

One obvious limitation is the possibility that the waiting space may in fact be limited. Another possibility is that arrival rate is state dependent. That is, potential customers are discouraged from entering the queue if they observe a long line at the time they arrive.


1 Answers

I would say the biggest disadvantage to a circular queue is you can only store queue.length elements. If you are using it as a buffer, you are limiting your history depth.

Another smaller disadvantage is it's hard to tell an empty queue from a full queue without retaining additional information.

like image 75
Justin Avatar answered Oct 13 '22 20:10

Justin