Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2021/imperative-programming-resit/2/c/solution

For an array of size , the first probe finds the uniformly selected target with probability . Otherwise it leaves a half of size ; conditional on entering that half, its target is uniform there. Counting the first iteration in every case gives
For , the successful-search decision tree has targets at depth , requiring iterations. Thus
The numerator is , as follows by induction or by shifting and subtracting a finite geometric sum. Substituting gives
The base gives one iteration, as required.

New to topics? Read the docs here!