DSA Visualizer
Binary search, step by step
Every comparison eliminates half of what's left. That's why binary search reaches a result in O(log n) comparisons instead of scanning every element.
The array is always sorted first — binary search only works on sorted data. Try 50: it isn't in the array, so you can watch the search correctly conclude that.
3
07
111
219
323
431
540
652
761
878
985
1093
11Step 1 of 9
Searching for 52 in a sorted array of 12. Binary search starts by looking at the middle of the whole range.