More than finding an exact value
Plain binary search looks for a target in a sorted array by halving the range each step. The modified binary search pattern keeps that halving discipline but bends it to answer richer questions: the first or last position of a value, a rotation point, a ceiling, or even a numeric answer that is not stored in any array.
Choosing which half to keep
Every variant rests on the same engine. You maintain a low and high boundary and inspect the middle.
- Decide, using a problem specific test, whether the answer lies left or right of the middle.
- Discard the half that cannot contain the answer by moving low or high.
- Keep narrowing until the boundaries meet.
The art is the test. For a rotated array you compare the middle against the ends to learn which side is still sorted, then check whether the target falls in that sorted half.
Searching an answer space
Some problems have no array at all. To find the smallest capacity or speed that satisfies a constraint, you binary search over the range of possible answers, using a feasibility check as the test. This turns an optimization into a sequence of yes or no questions.
Key idea
Keep binary search halving but replace the equality check with a problem specific test, so it locates boundaries, rotation points, and feasible answers, not just exact matches.