Questions: Binary Search

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You run binary search on an array that you believe is sorted, but it was accidentally left unsorted. The target value is present. What will happen?

ABinary search will still find the target — it checks all elements eventually
BBinary search will return an error because it detects the unsorted order
CBinary search may fail to find the target and return 'not found' even though it is present
DBinary search will find the target but will be slower than linear search
Question 2 Multiple Choice

Why does binary search achieve O(log n) time complexity?

ABecause it uses two pointers that move toward each other, halving the work at each step
BBecause each comparison eliminates half the remaining candidates, reducing n elements to 1 in at most log₂(n) comparisons
CBecause the midpoint calculation takes O(log n) time on modern hardware
DBecause it only checks elements at positions that are powers of 2
Question 3 True / False

Binary search can be applied to any problem where a monotonic predicate divides the search space into 'yes' and 'no' regions, not just to sorted arrays.

TTrue
FFalse
Question 4 True / False

Binary search can be applied to any array, sorted or not, as long as you know the target value you're looking for.

TTrue
FFalse
Question 5 Short Answer

What property of a sorted array allows binary search to eliminate half the candidates with a single comparison, and why does the same principle not apply to an unsorted array?

Think about your answer, then reveal below.