> For the complete documentation index, see [llms.txt](https://dsa-cpp.gitbook.io/nafees/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dsa-cpp.gitbook.io/nafees/binary-search-by-recursion.md).

# Binary Search By Recursion

## `Q1:`   [Binary Search](/nafees/binary-search.md#q1-binary-search)

```cpp
bool BinarySearch(int *arr, int s, int e, int k) {
    if (s > e)
        return false;
    int mid = s + (e - s) / 2;

    if(arr[mid] == k)
        return true;
    
    if(arr[mid] > k)
        return BinarySearch(arr, 0, mid-1, k);
    else
        return BinarySearch(arr, mid+1, e, k);
}
```
