C++ Binary search algorithm for arrays