Correct option is A
In a
circular queue, an
empty condition is typically represented by
both front and rear being -1.
Important Key Points:
1.
Empty Condition for Circular Queue:
· Initially, when the queue is
empty, both front and rear are
set to -1.
·
Condition:
if (front == -1 && rear == -1)
cout << "Queue is empty";
Knowledge Booster:
· In Circular Queues, insertion happens at the rear, and deletion happens at the front.
· Circular queues efficiently utilize memory by reusing empty spaces at the beginning of the array.
· The condition (rear + 1) % MAX_SIZE == front is used to check for a
full queue in circular queue implementations.
·
(b) Front = rear = 0 → ❌ Incorrect
· This condition
does not necessarily indicate an empty queue.
· If front = rear = 0, it may contain
one element.
·
(c) Front = rear + 1 → ❌ Incorrect
· This condition is
used for a full queue, not an empty one.
· The queue is
full when:
if ((rear + 1) % MAX_SIZE == front)
cout << "Queue is full";