Searching easy time O(log n) space O(1)
Binary Search
On a sorted array, compare the key with the middle element and throw away the half it cannot be in. Each step halves what’s left, so it finishes in log n comparisons.
Search a sorted array for 23. The whole array is in range.
1 / 6
Practice
Machine twin: /dsa-viz-v2/binary-search.json — the full deterministic run as structured data.