When a circular queue is implemented in an array of the following condition holds when there is only one element in the queue?
When a circular queue is implemented in an array of the following condition holds when there is only one element in the queue? Correct Answer Front=Rear – 1
Concept:
In circular queue, last element’s position is connected with the first element’s position. All other operations are same as queue. It also follows FIFO property (First in first out).
Explanation:
A circular queue is shown as:
[ alt="F1 Raju.S 04-09-2020 Savita D2" src="//storage.googleapis.com/tb-img/production/20/09/F1_Raju.S_04-09-2020_Savita_D2.png" style="width: 207px; height: 155px;">
For storing the front and rear in circular queue, we use rear = (rear + 1) % size and front = (front + 1) % size.
A circular queue will be full when Front = -1 and Rear = max – 1.
When a circular queue is implemented in an array, then when there is only one element in the queue, then Front=Rear – 1.