+ 1

# What is binary search?

2 Answers

+ 1

First of all it applicable only for sorted array.
Binary search compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful. If the search ends with the remaining half being empty, the target is not in the array.

0

Binary search is a algorithm used for searching some value in a list(array).
it only works on a sorted list.
How-
declare two variables-upper bound, lower bound.
run a loop find its mid value & target it. if you get what you want then break the loop. otherwise if number is < than what you want set lower bound = mid point (it depends on the way list is sorted here consider list sorted in ascending order).if number > than what you want set upper bound = mid point.