#include <stdio.h>
#define SIZE 15

int binarySearch(const int b[], int searchKey, size_t low, size_t high);

int main(void) {
    int a[SIZE];

    for (size_t i = 0; i < SIZE; ++i) {
        a[i] = 2 * i;
    }

    int key = 10;
    int result = binarySearch(a, key, 0, SIZE - 1);

    if (result != -1) {
        printf("Found value at index %d\n", result);
    } else {
        printf("Value not found\n");
    }

    return 0;
}

int binarySearch(const int b[], int searchKey, size_t low, size_t high) {
    if (low > high) {
        return -1;
    }

    size_t middle = (low + high) / 2;

    if (searchKey == b[middle]) {
        return middle;
    } else if (searchKey < b[middle]) {
        if (middle == 0) {
            return -1;
        }
        return binarySearch(b, searchKey, low, middle - 1);
    } else {
        return binarySearch(b, searchKey, middle + 1, high);
    }
}