The binary Search is a very efficient search algorithm applies only on ordered arrays

the main concept of binary search is to break the whole array into two halves and then check the value in the middle, if we’re searching for a value bigger than the value in the middle so it’d be at the right part otherwise it’d be in the left part
we will repeat this step in the resulted part by dividing it into two parts and vice versa.
we should make a stop point and it’d be in two cases

  1. if we ended with no division available in our array then it’ll we will notify that we didn’t find the value
  2. if we found the value we will return with the current index