Question Detail

COS 102 test topic Objective Question

Question

Which precondition must be satisfied before applying a binary search algorithm to a collection?
Options
A Elements must be non-negative integers
B The array must be sorted
Correct Answer
C The array size must be an exact power of two
D The collection must be implemented as a linked list
Correct Answer

Option B is the correct answer.

Detailed Explanation

Binary search relies on monotonic ordering across elements to divide the search space in half each iteration.

Hint

No hint available

Question Info