Circular Queue With front and rear
mediumQuestion 441RingQueue tracks front and rear instead of a size counter, which creates a problem: front == rear would mean both empty and completely full. The fix is to waste one slot on purpose - the queue calls itself full one slot early, so front == rear can only mean empty. With CAPACITY 5 that leaves room for 4 values. size() and toString() are written.
Requirements:
1. isEmpty() is true when front == rear.
2. isFull() is true when (rear + 1) % CAPACITY == front.
3. enqueue(int value): return false when full, otherwise store the value at rear, move rear forward with % CAPACITY and return true.
4. dequeue(): return -1 when empty, otherwise save items[front], move front forward with % CAPACITY and return the saved value.
Do NOT write a main method.
Expected output
true true true true true true false Queue: 10 20 30 40 4
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...