Trees & SearchD1Phase 1sorted-arraydivide-and-conquerbounds

Binary Search

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.

Arrays + Grid
Visualizer
O(log n)Binary Search
Deterministic search playback with active bounds, midpoint, and completion state.

Target

n/a

Low / High

0 / -1

Mid

n/a

Result

Searching

Ready

Press Play or Step to start execution.

No values available for visualization.
Binary Search Implementation
Pseudocode + TypeScript
Reference implementation examples are intentionally abstracted from the playback engine so learners can map concepts to code.
pseudocode
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
1.00xNo Run