Skip to content

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.

Step 1 of 9

Searching for 52 in a sorted array of 12. Binary search starts by looking at the middle of the whole range.