← Back to Data Structures & Algorithms
Question 440
Build the Circular Queue Core
Build the Circular Queue Core
This CircularQueue has its three fields declared but never set up, and both methods that move values are missing.toString()tells you what front and size must mean: it starts at front and walks size steps, wrapping with % CAPACITY. Requirements: 1. Give items an array of CAPACITY slots and start front and size at 0. 2.enqueue(int value): return false when full, otherwise store the value at (front + size) % CAPACITY, grow size and return true. 3.dequeue(): return -1 when empty, otherwise saveitems[front], move front forward with % CAPACITY, shrink size and return the saved value. Do NOT write a main method.
Expected Output:
true Queue: 10 20 30 40 50 true false 10 20 true true Queue: 30 40 50 60 70 5
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
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.