Binary Search

Divide and conquer search on sorted arrays - O(log n) time complexity

Size:
Target:
Speed:
Current Mid
Search Range
Excluded
Found

About Binary Search

Time Complexity:

  • Best: O(1) - target at middle
  • Average: O(log n)
  • Worst: O(log n) - not found

Space Complexity: O(1)

Requirement: Sorted Array

How It Works

Binary Search efficiently finds a target value in a sorted array by repeatedly dividing the search space in half.

Each comparison eliminates half of the remaining elements, resulting in logarithmic time complexity.

💡 Tip: The array must be sorted for binary search to work correctly. Watch how the search range shrinks by half each step!