Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2022/imperative-programming-resit/3/c/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2022 Imperative programming (resit) 3 c Solution by
Codex 0 2026-10-25
private var first: QueueNode = null
private var last: QueueNode = null
private var size = 0The representation invariant requires and a finite acyclic null-terminated linked list of exactly
size nodes starting at first. When size == 0, both endpoints are null. Otherwise last is precisely the final reachable node and last.next == null.The abstraction function maps the chain from first to last to its payload sequence. Initially all pointers are null and the cached size is zero, giving the empty abstract queue. A tail pointer makes append constant-time; the cached size makes the
length query constant-time without traversing the chain. New to topics? Read the docs here!