Skip to content
Tactiverge

Olympiad · Practice · public practice problem

Searching the calibration table

Difficulty 3 of 511 points in 4 partsSuggested time ~20 min (never timed here)

The problem

A motor controller looks up values in a sorted table. Binary search keeps a range lo..hi, probes mid = (lo + hi) // 2, and moves lo = mid + 1 or hi = mid - 1 until it finds the value or the range is empty.

Small table (indices 0 to 9): [3, 8, 15, 21, 30, 42, 57, 64, 71, 88].

Large table: 1024 entries.

  1. Part (a) · 3 points

    Searching the small table for 57 (starting lo = 0, hi = 9), how many probes are made, counting the one that finds it?

    (pure number)Tolerance: exact

  2. Part (b) · 3 points

    What is the worst-case number of probes for binary search in the 1024-entry table?

    (pure number)Tolerance: exact

  3. Part (c) · 2 points

    Linear search checks entries from the start. Averaged over every entry being the target once, how many checks does it make in the 1024-entry table?

    (pure number)Tolerance: exact

  4. Part (d) · 3 points

    If the table arrived unsorted, sorting it costs about n log₂ n = 10 240 comparisons. What is the smallest number of searches for which sort-then-binary-search (worst case 11 each) beats linear search (512.5 each on average)?

    (pure number)Tolerance: exact

Checked so far: 0 of 11 automatically marked points. Nothing is saved.

Stuck? Hints, then the worked solution

Written with AI assistance. Review status: technically-checked (answers recomputed independently with units verified by automated tests); not yet reviewed by an educator or judge.