Binary Search (step demi step) Playground

Mr. Sugeng halves the long floor to find one sack: lo, mid and hi at every step of code that really runs. What becomes of `lo = mid`, a fractional mid, an…

Why it matters

Binary search is everywhere: database indexes, git bisect, finding the version that broke things, guessing a limit. But it is fragile: one missing + 1 makes the while never stop, and an unsorted row makes its answer wrong without any error message.

The key idea

Every weighing throws away half, if the row is sorted

Common mistakes

Try it in this playground