Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2014/imperative-programming/4/a/solution

The fresh array initially holds null references, whereas a zero row must be an empty list. Initialize every slot explicitly:
for (i <- 0 until N) rows(i) = List.empty[Entry]
Then
The following methods belong inside SparseMatrix, using the supplied Entry and Row type aliases.

New to topics? Read the docs here!