CJCoding With Joseph
15free / daySign inCreate account

Enqueue at the Tail of a Linked Queue

LinkedQueue adds at the tail and removes at the head, so it tracks both ends. Every method except enqueue is already written.

Requirements:
1. Complete enqueue(int value) so it wraps the value in a new Node and links it on after the current tail.
2. When the queue is empty, head and tail must both end up pointing at the new node.
3. Increase size either way.

The Node class is provided - do not rename it and do not add public to it, because a Java source file may contain only one public class.

Do NOT write a main method.

Expected Output:

10 -> null
10 -> 20 -> 30 -> null
3
10

= newline. The output ends with a newline — 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.