Algorithms and Data Structures · Junior · Question 31 of 75
What does binary search require from the data?
- ✓Correct answer: The array must be sorted
- 2All values must be unique
- 3The array must have an even length
Explanation
Binary search compares the target with the middle element and discards the half where it cannot be. That decision only makes sense if the array is sorted. Duplicates are fine.