This older article on java67.com explores and explains binary search algorithm. The binary search algorithm is one of the fundamental Computer Science Algorithms and used to search an element in a sorted input set.

It’s much faster than the linear search which scans each and every element and improves performance from O(n) to O(logN) for searching an element in the array

In order to perform the binary search, you need a sorted array. In this article, we will write a Java program which will take input from the user, both array and the number to be searched and then perform a binary search to find that number in a given array.

In a binary search algorithm, you first find the middle element of the array and compare that with the number you are searching. Several important data structures like binary search tree and binary heap are based upon the binary search algorithm.

Binary search works on the principle of **divide and conquer**. In this technique, a solution is found by dividing the input on some smaller set using some rules.

For the solution in Java follow the link to original article. Well worth your time!

[Read More]