Bisection is a search technique: when a bug is somewhere in a large region of code or input, you find the midpoint, check whether the bug is on the "before" side or the "after" side, and repeat, each step halves the remaining search space. For code, that means dropping a printf (or a breakpoint) halfway through the suspect region, checking whether the program's state at that point is correct, and then narrowing to either the first or second half. For commits, git bisect automates this against a known-good and known-bad commit. For input data, you can binary-search through inputs to find which one triggers the bug. Bisection takes logarithmic time in the search space, 1024 lines becomes 10 print statements instead of 1000. It works for almost any kind of bug, in any language, and is the single most effective debugging skill to internalize.
Programming Fundamentals · Interview question
What is bisection in debugging?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Errors & Debugging
Errors are messages from the compiler trying to help. Learn to read them, distinguish the three kinds of bugs, and build the mindset that turns debugging from frustration into a skill.