Array search

Halves a sorted range each step by comparing the middle element to the target, discarding the half that can't contain it.

Searching for:Binary Search: O(log n)
6121419202531354244505661626669767985919394100102104105109116118119

Real-time /ps log

lo = 0, hi = n-1
while lo <= hi:
mid = (lo + hi) / 2
if arr[mid] == target: return mid
if arr[mid] < target: lo = mid + 1
else: hi = mid - 1
return NOT_FOUND
Comparisons: 0Found at index: Theoretical steps: log₂(30) ≈ 4.9