#DS
I have this confusion in concluding the overflow condition of a circular Queue i.e. when the circular queue will be considered full.
As per the text i have, it says a circular queue is full when:
Front=0 and Rear=MAX-1 ; which seems quite straight forward.
eg: The queue [10,5,8,6,4] where MAX=5, Front=0 and Rear=4 looks full. But if we carry a single Dequeue operation and a single Enqueue operation for inserting 12, we will see:
[12,5,8,6,4] where MAX=5, Front=1, Rear=0
In the above situation, Front isn't 0 and Rear isn't Max-1, although still the queue is quite full. So my question is shouldn't the overflow condition of a circular Queue be:
if((Front==0 && Rear==MAX-1) || (Rear==Front-1))
???