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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *