Theory
Code
Complexity Analysis
Searching is an important operation in every-day life and even in many software applications, as we frequently search for data!
Searching is a method to find some relevant information in a data set
Lets try to search for Number 12.
Can we do better? Can we exploit the information that array is sorted?
Binary Search is an algorithm that can be used to search an element in a sorted data set.
By sorted, we mean that the elements will either be in a natural increasing or decreasing order.
Lets try to search for Number 12.
What is the number doesn't exist? Lets try to search for 6.
Binary Search is a Divide & Conquer Algorithm.
It divides the array into two halves and tries to find the element K in one or the other half, not both. It keeps on doing this until we either find the element or the array is exhausted.