The Interval Collapse
O(log n) made visible.
This animation runs binary search on a sorted array and makes the discarding physical.
Brackets mark the live search range [lo, hi] — the only region that can still contain the target. Each step, a spotlight drops on the middle element, it flips to reveal its comparison against the target, and then the half that cannot hold the target sweeps to gray. The brackets slide inward and the process repeats on what is left.
Two things to watch. First, the invariant: at every frame, if the target exists at all, it is between the brackets. Gray cells are not "probably wrong" — they are proven impossible, which is why they never come back. Second, the gauge on the side: it tracks the live range shrinking n → n/2 → n/4 → ... Count the steps it takes to reach a single cell. For 16 elements it is 4 steps; for a million it would be about 20. That gauge is O(log n) — the running time is just "how many times can you halve n".
Watch also how mid is always excluded after its comparison: the brackets land at mid + 1 or mid - 1, never on mid itself. That one-cell exclusion is what guarantees the loop finishes.