|
|
@ -1,7 +1,7 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Write a recursive function that searches for a target in a sorted array using
|
|
|
|
Write a recursive function that searches for a target in a sorted array using
|
|
|
|
binay search, where the array, its size and the target are given as parameters.
|
|
|
|
binay search, where the array, its size and the target are given as parameters.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdio.h>
|
|
|
@ -51,7 +51,8 @@ int main(void) {
|
|
|
|
21090, 22277, 22624, 24634, 24877,
|
|
|
|
21090, 22277, 22624, 24634, 24877,
|
|
|
|
25367, 25586, 26706, 26720, 26958,
|
|
|
|
25367, 25586, 26706, 26720, 26958,
|
|
|
|
27478, 28269, 29142, 30630, 30804,
|
|
|
|
27478, 28269, 29142, 30630, 30804,
|
|
|
|
31984, 32398, 32588 };
|
|
|
|
31984, 32398, 32588
|
|
|
|
|
|
|
|
};
|
|
|
|
assert_sorted(a, 43);
|
|
|
|
assert_sorted(a, 43);
|
|
|
|
|
|
|
|
|
|
|
|
assert(binsearch(a, 43, 912) == 0);
|
|
|
|
assert(binsearch(a, 43, 912) == 0);
|
|
|
|