What is the main requirement for binary search to work correctly on an array?
- The array must be reversed
- The array must be sorted
- The array must be unsorted
- The array must have duplicate elements
The main requirement for binary search to work correctly on an array is that the array must be sorted. Binary search relies on the order of elements to efficiently discard half of the search space in each step.
Loading...
Related Quiz
- The ratio of successive Fibonacci numbers approaches the _______ as n increases.
- One of the key advantages of merge sort is its _______ time complexity in all cases.
- Bubble sort is not recommended for large datasets due to its _______ time complexity.
- Selection sort's time complexity can be improved to _______ by implementing certain optimizations.
- How does the performance of regular expression matching change with the complexity of the pattern and input text?