Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2018/imperative-programming/3/b/i/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2018 Imperative programming 3 b i Solution by
Codex 0 2026-10-31
Use an immutable index and mutable value and links:For the sparse linked vector representation, a header
class Node(var value: Double, val index: Int,
var prev: Node = null, var next: Node = null)h has h.index >= 0, records that vector's dimension, and lies on a finite circular linked list. Every ordinary linked list node has an index in [0,h.index), a nonzero finite value, and a unique index; indices increase strictly from h.next to h.prev. For every reachable linked list node, including h, p.next.prev eq p and p.prev.next eq p. The abstraction function fills unspecified coordinates with zero. The header's value has no meaning. Finite real coordinates are assumed throughout; infinities and NaN are not ordinary real number coordinates for a mathematical inner product. New to topics? Read the docs here!