July 2018
Beginner
202 pages
5h 4m
English
We need to write a safe enqueue() method that will fail when the queue is full.
Steps for completion:
public boolean enqueueSafe(V item)public Optional<V> dequeueSafe()
private boolean full = false;public boolean enqueueSafe(V item) { if (!full) { array[tailPtr] = item; tailPtr = (tailPtr + 1) % array.length; this.full = tailPtr == headPtr; return true; ...Read now
Unlock full access