What common boundary mistake can cause an infinite loop?
Practice this question from Binary Search - Classic search Pattern Practice Quiz, with options and an explanation.
Question
What common boundary mistake can cause an infinite loop?
Option A — Correct answer
Not moving past mid when shrinking the range
Option B
Using a safe midpoint formula
Option C
Returning when target is found
Option D
Checking sorted order first
Explanation
Not moving past mid when discarding a half can keep the same range forever.