= Solution
The runtime <precondition> check rules out negative dimensions:
``
def makeZeroVector(size: Int): Node = {
require(size >= 0)
val h = new Node(0.0, size)
h.prev = h
h.next = h
h
}
``
Both links point to the fresh <list header>, so all reciprocal-link conditions hold and there are no ordinary entries to violate ordering or nonzero-value requirements. The <abstraction function> therefore yields \b[the zero <vector> of dimension `size`]. Construction uses <constant time> and <constant space>.
Back to article page