Data Structures & AlgorithmsModerateProduct Company SDE · binary search round

Problem: Which claim about a binary search over a rotated sorted array (no duplicates) finding the minimum element is correct?

  1. A. It needs O(n) because the rotation point could be anywhere
  2. B. It runs in O(log n) by comparing the middle value with the right end to decide which half holds the rotation point
  3. C. It is impossible because the array is not sorted
  4. D. It runs in O(sqrt n) with block jumps

Correct answer: B. It runs in O(log n) by comparing the middle value with the right end to decide which half holds the rotation point

If the middle is greater than the right end, the minimum lies to the right; otherwise it lies in the left part including the middle. Each step halves the range.

More Coding Interview Problems questions

Exams that ask this topic