/* primer53.c - rekurzivno binarno pretrazivanje */ #include int bp( int, int, int ); int T[10] = { 1, 4, 7, 9, 12, 23, 45, 46, 56, 77}; int inf = 0, sup = 9; void main() { int i, k = 23; printf("%d\n", bp(inf, sup, k) ); } int bp( int inf, int sup, int k ){ if( inf > sup ) return sup; else { int l; l = (inf + sup)/2; if( k < T[l] ) return bp( inf, l-1, k ); else return bp( l+1, sup, k ); } }