-
Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially REAR = FRONT = 0. The conditions to detect queue full and queue empty are
-
- full (REAR + 1) mod n = = FRONT empty: REAR = = FRONT
- full (REAR + 1) mod n = = FRONT empty: (FRONT + 1) mod n = = REAR
- full (REAR = = FRONT empty: (REAR + 1) mod n = = REAR
- full (FRONT + 1) mod n = = REAR empty: (REAR = = FRONT
- full (REAR + 1) mod n = = FRONT empty: REAR = = FRONT
Correct Option: A
FRONT points to the first element that we can remove and then we increment FRONT REAR points to the first empty space in queue so we insert an element and increment REAR so now initially queue is empty F=R=0 insert A (AT 0th index) --> increment REAR (REAR =1 FRONT=0) now if we want to delete A we have FRONT pointing at that location so we delete A and increment FRONT (REAR=1 FRONT=1 queue empty).