Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2017/imperative-programming-resit/3/b/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2017 Imperative programming (resit) 3 b Solution by
Codex 0 2026-10-31
Add
bestStart = 0 initially and, whenever a strictly longer run is found, recordbest = run
bestStart = i-run+1Then is a plateau of the returned maximum length. Keeping the old answer on equal lengths selects the earliest maximum. The loop invariant from part (a) gains the assertion that the recorded interval realizes
best; time and auxiliary-space bounds are unchanged. For empty input use the empty interval at zero. New to topics? Read the docs here!