Low-level search baseline illustrating midpoint decision boundaries.
Easy Explanation
Binary Search checks the middle of a sorted list and discards half each step until it finds the target.
Renderer Mode
`Simple` uses abstract, short-form-friendly visuals. `Advanced` keeps the current detailed view.
Target
n/a
Low / High
0 / -1
Mid
n/a
Result
Searching
Press Play or Step to start execution.
function binarySearch(values, target):
low <- 0
high <- length(values) - 1
while low <= high:
mid <- low + floor((high - low) / 2)
if values[mid] == target:
return mid
if values[mid] < target:
low <- mid + 1
else:
high <- mid - 1
return -1