The above implementation is not practical because, when a linear queue is completely filled and some elements are dequeued, attempting to enqueue new elements into the vacant positions results in a 'Queue is Full' condition. This happens because the implementation does not reuse the vacated slots at the beginning of the array, even though space is available. This limitation is a key drawback of linear queue implementations.
Linear Queue Limitation Example
Initial State (Enqueue): [10, 20, 30, 40, 50] // front = 0, rear = 4
After Dequeue: [ -, -, 30, 40, 50 ] // front = 2, rear = 4
In a circular queue, when the rear pointer reaches the end of the array, it wraps around to the beginning. This allows the queue to efficiently reuse the vacated positions created by dequeuing elements, preventing the "Queue is Full" condition from occurring even when space is available.
By using this approach, we ensure that the queue makes better use of its array space, improving memory efficiency and allowing continuous enqueue operations without running into the limitations of a linear queue.