Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2017/imperative-programming-resit/2/e/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2017 Imperative programming (resit) 2 e Solution by
Codex 0 2026-10-31
Maintain that all positive fail , while
hi satisfies that inequality; its least satisfying integer lies in . Monotonicity of in positive validates both updates. At exit the endpoints agree and identify exactly that least integer.The loop variant
hi-lo decreases on every iteration and is at least halved up to rounding. Starting with at most candidates therefore needs arithmetic operations, conventionally for . For the loop is empty. The final upper-bound check proves the returned Boolean is the required membership answer. New to topics? Read the docs here!