In binary search, what happens in each step of the algorithm?

  • Adjacent elements are swapped
  • Elements are randomly rearranged
  • The middle element is compared with the target, and the search space is narrowed
  • The smallest element is moved to the end
In each step of the binary search algorithm, the middle element of the current search space is compared with the target value. Depending on the result, the search space is either halved or the target is found.
Add your answer
Loading...

Leave a comment

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