Search in a Rotated Sorted Array
Identify the sorted half at each binary-search probe and keep the half that can contain the target.
Core idea
A rotated sorted array still has at least one sorted half around every midpoint. Determine that half, test whether the target falls inside its value range, and discard the other half.
Read the visualization
Low, midpoint, and high pointers bound the candidate interval. Each step labels the sorted half and visibly removes the half that cannot contain the target.
Begin with the entire rotated sorted array as the candidate interval.
Complexity and tradeoffs
Time: O(log n). Space: O(1). The logarithmic guarantee assumes distinct values; duplicates can obscure which half is sorted.
Where it fits
This pattern handles searches across one unknown cyclic pivot. Repeated values may make both halves ambiguous and can degrade the worst case to linear time.