Can someone explain to me how binary search works exactly? I tried googling it, but it makes no sense? Can someone give me a very simple explanation for it?
Binary search searches for the value in sorted array by comparing the value to the value in the middle of the array, and continues search by using the same pattern each time "halving" the array until value is found.
The point is that searching is fast since searched value is not compared against each value in the array, instead halving the array as many time as needed.
which half of the array is chosen depends on value in the middle and the value being searched.