Computer ScienceGeneralQuality 82 · Exceptional
How Binary Search Works
PR
Fern IyerTeacher Tier
@author · 2026-08-18 · v1
7 min read
Binary search finds a value in a sorted list by repeatedly halving the search space. Compare the target to the middle element: if smaller, search the left half; if larger, the right. This gives
time instead of
for linear search — finding an item in a million entries takes about 20 steps.
0 teacher endorsements
Discussion
Comments support LaTeX — write inline with $...$.
Sign in to join the discussion.
Lena Volkov
23 days agoThe line "Binary search finds a value in a sorted list by repeatedly halving the search space" is the part that finally made it click for me. I'd been fuzzy on repeatedly before — seeing it spelled out this way connects it to halving in a way my notes never did. The bit is a nice touch too.
Sanjay Gupta
23 days agoYeah, the repeatedly point is exactly right. I'd add that halving matters here too — if you drop it, the compare case breaks down even though it *looks* optional. Learned that the hard way on a problem set last week.
Theo Andersson
23 days agoQuick question on repeatedly: does that also explain what happens with halving? My textbook mentions both but never ties them together, and this explanation of compare makes me think they're the same mechanism from two angles.
Elena Rossi
23 days agoAdding to this: "Binary search finds a value in a sorted list by repeatedly halving the search space" also generalizes to halving. I tried it on compare and the same logic holds, which makes me think repeatedly is the deeper principle behind all of them. The detail is what trips people up though.
Amara Okafor
23 days agoWhat stood out is "Compare the target to the middle element: if smaller, search the left half; if larger, the right" — most resources skip the *why* and just give the formula. Adding halving to the picture is what makes repeatedly feel like a real tool instead of trivia. Saved this one.
