DSA · interactive
Binary search
The list is sorted. Each probe checks the middle and throws away the half that cannot hold 22.
Probe 1 of 3
lo 0 · mid 4 · hi 9
- 3lo
- 7
- 11
- 14
- 19mid
- 22
- 28
- 35
- 41
- 50hi
19 is below 22. Keep the right half.
Probe 1: 19 is below 22. Keep the right half.
Target
1 lo and hi are the first and last cells that might still hold the target.
10 cells left, from index 0 to 9.
2 3 4
Now solve it
Binary Search: 9 problems
See all →In production
Tools and technologies
Binary search is an algorithm on sorted data; libraries only save you from writing the loop.
Not tied to one language — use these names when you search docs or design a system.