Computer ScienceGeneralQuality 72 · Exceptional

How Binary Search Works

PR
Gus StrandTeacher Tier
@author · 2026-06-13 · 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
O(log⁡n)O(\log n)
time instead of
O(n)O(n)
for linear search — finding an item in a million entries takes about 20 steps.
0 teacher endorsements

Discussion

Comments support LaTeX — write ∫01x2 dx\int_0^1 x^2\,dx inline with $...$.

Sign in to join the discussion.

Dr. Tan
16 days ago
This is the kind of contribution CampusWorld needs more of.
Dr. Webb
16 days ago
Quick question: does this hold for the advanced case too?
Yuki S.
16 days ago
Bookmarked. Coming back to this before the exam.
Ravi P. Teacher
16 days ago
Agreed — the step-by-step is what made it land for me too.