Professional Documents
Culture Documents
Programming 2
1. Firstly find the middle element of the array and compare with the
value the user wanted to search.
2. If they are same then it will return the location of the required
value.
3. If they are not equal then it will break the array in half
4. If the middle of array is smaller than the required number then it
will search the first half of an array.
5. If the middle of array is greater than the required number then it
will search the second half of an array.
6. This process will continue until the required value is found or until
the loop terminates or complete without finding the required value.
Example of Binary Search:
Important Differences of Linear and Binary
Search