Binary search algorithm is an algorithm for searching a target value in an array. The steps of binary search algorithm are as follows.
Choose the middle value as a key value, dividing a sorted array into two parts.
Compare the target value and the key value.
If the target value is larger than the key value, then put the part in which the values are less than the target out of the search area, and return to step 1, and vice versa.
If the key value is equal to the target value, give an output. Else not any value can be found equal to the target though there's no part can be put out of the search area.
Binary search algorithm is one of the general algorithm for searching a target value in an array. It is always the most efficient way to search a number in a Large number of data, which make itself been wildly applied.