recursive binary search

#include <iostream>
using namespace std;

int binarySearchRecursive(int arr[], int low, int high, int target);

int main() {
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int target = 6;
    int size = sizeof(arr) / sizeof(arr[0]);
    int result = binarySearchRecursive(arr, 0, size - 1, target);

    if (result != -1) {
        cout << "Element found at index " << result << endl;
    } else {
        cout << "Element not found in the array" << endl;
    }

    return 0;
}

int binarySearchRecursive(int arr[], int low, int high, int target) {
    if (low <= high) {
        int mid = low + (high - low) / 2;

        if (arr[mid] == target) {
            return mid;
        }

        if (arr[mid] > target) {
            return binarySearchRecursive(arr, low, mid - 1, target);
        }

        return binarySearchRecursive(arr, mid + 1, high, target);
    }

    return -1;
}