Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2022/imperative-programming-resit/3/b/solution

A node needs a stored value and one successor reference:
final class QueueNode(val value: Int, var next: QueueNode)
A null successor terminates the chain. The stored value need not be mutable for a FIFO queue, because enqueue creates a node and dequeue removes one rather than changing its payload.

New to topics? Read the docs here!