VISUALGO//SEARCH
binary search · array trace console · O(log n)
Goal:Find 7 in a sorted array by repeatedly halving the search range. Grayed sections are eliminated.
3
0
4
1
7
2
16
3
29
4
31
5
49
6
52
7
61
8
66
9
80
10
99
11
▲
LOW
▲
HIGH
ELEMENTS
TARGET
READOUT
step0 / 4
comparisons0
result—
statusIDLE