Skip to content

Binary search [mp]

Micro pattern

Description

Repeatedly discard half of a search space while preserving an invariant that contains the answer.

Problems

Continue narrowing after finding a candidate to locate the first or last valid position.

Use a sorted half, slope, or partition violation to select the remaining half.

Search over maintained tails

Binary-search a compact summary to find the state to extend or replace.

Binary search on the answer

Search a numeric domain with a monotone counting or feasibility predicate.