CJCoding With Joseph
15free / daySign inCreate account

ShiftQueue can already accept values and print itself, but nothing stops it reading a slot it does not own. Three missing methods have to agree.

Requirements: 1. isEmpty() reports whether the queue holds no values. 2. peek() returns -1 when empty, otherwise the front value, removing nothing. 3. dequeue() also returns -1 when empty, otherwise saves items[0], shifts the later values one slot left, decreases size and returns the saved value. 4. peek() and dequeue() must both decide the empty case by calling isEmpty().

Do NOT write a main method.

Expected output

true
-1
-1
false
4
Queue: 4 8
4
8
true
-1

= newline. The output ends with a newline, so print one after the last line.

Hints4 available
Topics
Data Structures & AlgorithmsQueues
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.