#include <stdio.h>
int RecursionHalfSearch(int a[], int left, int right, int key) {
    if (left <= right) {
        int middle = (left + right) / 2;
        if (key == a[middle])
            return middle;
        else if (key > a[middle])
            return RecursionHalfSearch(a, middle + 1, right, key);
        else
            return RecursionHalfSearch(a, left, middle - 1, key);
    } else {
        return -1;
    }
}

int main() {
    int a[] = {1, 3, 5, 7, 9};
    int size = sizeof(a) / sizeof(a[0]);
    int key = 7;
    int index = RecursionHalfSearch(a, 0, size - 1, key);
    if (index != -1)
        printf("Element found at index %d\n", index);
    else
        printf("Element not found\n");
    return 0;
}
