Binary Search

Binary search is the most popular Search algorithm. It is efficient and also one of the most commonly used techniques that are used to solve problems. If all the names in the world are written down together in order and you want to search for the position of a specific name, binary search will accomplish this in a maximum of 35 iterations. Binary search works only on a sorted set of elements. To use binary search on a collection, the collection must first be sorted. When the binary search is used to perform operations on a sorted set, the number of iterations can always be reduced on the basis of the value that is being searched. Let us consider the following array: By using a linear search, the position of element 8 will be determined in the 9 t h iteration. Let's see how the number of iterations can be reduced by using a binary search. Before we start the search, we need to know the start and end of the range. Let's call them...