What is binary search?

For binary search, the array should be arranged in ascending or descending order.

In each step, the algorithm compares the search key value with the middle element of the array. If the key match, then a matching element has been found and its index, or position, is returned.

Otherwise, if the search key is less than the middle element, then the algorithm repeats its action on the sub-array to the left of the middle element or, if the search key is greater, on the sub-array to the right.

 

0
Sanisha Maharjan
Jan 23, 2022
More related questions

Questions Bank

View all Questions