When nums[mid] is less than target, what should happen?

Practice this question from Binary Search - Classic search Pattern Practice Quiz, with options and an explanation.

Question

When nums[mid] is less than target, what should happen?

Option A

Move right to mid - 1

Option B — Correct answer

Move left to mid + 1

Option C

Return -1 immediately

Option D

Sort again

Explanation

Move the left boundary to mid + 1 because the target can only be on the right.

Binary Search - Classic search Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker