How Queue Works
Queue operations work as follows:
1. Two pointers called FRONT and REAR are used to keep
track of the first and last elements in the queue.
2. When initializing the queue, we set the value
of FRONT and REAR to -1.
3. On enqueuing an element, we increase the value
of REAR index and place the new element in the position
pointed to by REAR.
4. On dequeuing an element, we return the value pointed to
by FRONT and increase the FRONT index.
5. Before enqueuing, we check if the queue is already full.
6. Before dequeuing, we check if the queue is already
empty.
7. When enqueuing the first element, we set the value
of FRONT to 0.
8. When dequeuing the last element, we reset the values
of FRONT and REAR to -1.