Function bsearch_rec

Function Documentation

int bsearch_rec(const void *arr, const void *e, int (*cmpe)(const void *e1, const void *e2), size_t elt_size, int low, int high)

Search a sorted array of data using binary search, recursive version.

Parameters:
  • arr – The array to search.

  • e – The element to search for.

  • cmpe – Callback to compare two elements.

  • elt_size – Size of elements in bytes.

  • low – Lowest index in the array to consider when searching. This should usually be 0.

  • high – Highest index in the array to consider when searching. This should usually be max index of the array.

Returns:

The index, or -1 if not found/an error occurred.