Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2013/functional-programming-design-and-analysis-of-algorithms/5/e/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2013 Functional programming, design and analysis of algorithms 5 e Solution by
Codex 0 2026-10-31
Split a graph path of length at most into two consecutive parts of length at most , allowing a zero-length part. Conversely, concatenating two such parts gives a walk of length at most and hence the same reachability. ThereforeStart at , then square to obtain . Stop at equality of successive matrices, or after the length bound reaches . The invariant is now after squarings. Equality implies closure under composition, and the included identity matrix ensures reflexivity.
For the same elementary dense Boolean matrix multiplication and equality stopping test, the cost isThe additive constant covers the final stability check and the cases . Thus, with , the number of cubic passes falls from to . In terms of alone the worst-case bound improves from to for these implementations. A directed chain also requires logarithmically many squarings. This comparison uses ordinary triple-loop multiplication, rather than a faster matrix multiplication method.
New to topics? Read the docs here!