Imperative programming (source code)

= Imperative programming
{scope}
{title2=A10098W1}

This is the 14 June 2017 preliminary examination. All 38 printed subparts are answered. Source paper: https://www.whatdotheyknow.com/request/past_exam_papers_for_1st_year_of/response/1398416/attach/2/Fakour%20Zip%20Final%201.zip?cookie_passthrough=1[released examination archive], member `a10098w1-2.pdf`.

Questions 1–4 use explicit pseudocode: array segments are half-open, a `var` parameter can be reassigned in the caller, newly allocated cells are initialized by the code, and integer arithmetic is exact. Assume a radix at least two, finite valid acyclic linked lists, and a total ordering where keys are compared. Implementations with fixed-width temporary integers need a radix and bounds that avoid overflow. Questions 5–8 use the Scala 2 API style of the source, with separate namespaces for independent examples. Scala code is not claimed to have been compiled in the current environment.