Algorithms_in_C
1.0.0
Set of algorithms implemented in C.
|
Program to perform binary search of a target value in a given sorted array. More...
#include <assert.h>
#include <stdio.h>
Functions | |
int | binarysearch1 (const int *arr, int l, int r, int x) |
Recursive implementation. More... | |
int | binarysearch2 (const int *arr, int l, int r, int x) |
Iterative implementation. More... | |
void | test () |
Test implementations. | |
int | main (void) |
Main function. | |
Program to perform binary search of a target value in a given sorted array.
int binarysearch1 | ( | const int * | arr, |
int | l, | ||
int | r, | ||
int | x | ||
) |
Recursive implementation.
[in] | arr | array to search |
l | left index of search range | |
r | right index of search range | |
x | target value to search for |
int binarysearch2 | ( | const int * | arr, |
int | l, | ||
int | r, | ||
int | x | ||
) |
Iterative implementation.
[in] | arr | array to search |
l | left index of search range | |
r | right index of search range | |
x | target value to search for |