Given a sorted array of integers, write a function that checks whether an integer, target, exists in the array. If it exists, return true, otherwise false.
```cpp
// IMPLEMENT HERE
int binary_search(int target, int *elems, int n) {
if (n == 0)
return 0;
int mid = n / 2;
if (elems[mid] == target) return 1;
else if (elems[mid] > target) binary_search(target, & elems[0], n / 2);
else binary_search(target, & elems[mid + 1], n / 2 - 1);
}
```