Search AlgorithmsBeginner

Binary Search

Highly efficient search method that compares the target with the middle element and repeatedly halves the search space. With O(log n) time, it can find an item in 1 million elements in just 20 comparisons. Works like looking up words in a dictionary.

#searching#divide-and-conquer#efficient

Complexity Analysis

Time (Average)

O(log n)

Expected case performance

Space

O(1)

Memory requirements

Time (Best)

O(1)

Best case performance

Time (Worst)

O(log n)

Worst case performance

📚 CLRS Reference

Introduction to AlgorithmsChapter 2Section 2.3-5

Step: 1 / 0
500ms
SlowFast
Keyboard Shortcuts
Space Play/Pause StepR Reset1-4 Speed

Real-time Statistics

Algorithm Performance Metrics

Progress0%
Comparisons
0
Swaps
0
Array Accesses
0
Steps
1/ 0

Algorithm Visualization

Step 1 of 0

Initialize array to begin

Default
Comparing
Swapped
Sorted

Code Execution

Currently executing
Previously executed

Implementation

Binary Search - Algorithm Vision