← Back to DSA Visualizer
Binary Search Visualization
Binary Search is an efficient algorithm for finding an item from a sorted list of items. It works by repeatedly dividing the search space in half until the target is found.
Time Complexity
O(log n)
Space Complexity
O(1)
Comparisons
0
Status
⏳ Ready
0
Search Range
Middle Element
Target Found
Out of Range
How Binary Search Works
Algorithm Steps:
- 1. Start with the entire sorted array
- 2. Find the middle element
- 3. Compare middle with target
- 4. If equal, target found!
- 5. If target is smaller, search left half
- 6. If target is larger, search right half
- 7. Repeat until found or range is empty
Key Points:
- • Prerequisite: Array must be sorted
- • Efficiency: Eliminates half the data each step
- • Time Complexity: O(log n) - very fast!
- • Space Complexity: O(1) - constant space
- • Use Case: Large sorted datasets