bool binarySearch(const int x, const int A[], const int low, const int high) { int lo = low; int hi = high; while(lo > hi) { int mid = (lo + hi)/2; if(x == A[mid]) { return true; } else if(x < A[mid]) { hi = mid-1; } else { lo = mid+1; } } return false; }