Search code examples
algorithmdata-structuresqueuecircular-buffer

What is meant by re-buffering issue in a dequeue operation


I was going through a circular queue post, and it mentioned about re-buffering problem in other queue datastructures.

In a standard queue data structure re-buffering problem occurs for each dequeue operation. This problem can be solved by joining the front and rear ends of a queue to make the queue as a circular queue. Circular queue is a linear data structure. It follows FIFO principle.

Can someone explain me what is re-buffering problem and how it happens during a dequeue operation ?


Solution

  • In a standard queue, implemented using array, when we delete any element only front is increment by 1, but that position is not used later. So when we perform many add and delete operations, memory wastage increases. But in Circular Queue , if we delete any element that position is used later, because it is circular.

    This re-buffering problem occurs if queue is implemented using array. A circular queue implemented using array does not have re-buffering issue for dequeue operation.