Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2021/imperative-programming/5/c/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2021 Imperative programming 5 c Solution by
Codex 0 2026-10-25
Membership is exactly whether the bucket search finds an entry:
def isInBook(name: String): Boolean = {
find(name, table(hash(name))) != null
}By the bucket-placement representation invariant, an entry with this name can occur only in this bucket. The
find contract therefore proves true exactly for keys in the map's domain, with no state change. One hash calculation and one bucket traversal suffice; no insertion is performed during the query. New to topics? Read the docs here!