1int binarySearch( const int b[], int searchKey, int low, int high )
2{
3 int middle = ( low + high ) / 2;
4 if ( searchKey == b[ middle ] )
5 return middle;
6 else if ( searchKey < b[ middle ] )
7 return binarySearch( b, searchKey, low, middle - 1 );
8 else if ( searchKey > b[ middle ] )
9 return binarySearch( b, searchKey, middle + 1, high );
10 else
11 return -1;
12}
2{
3 int middle = ( low + high ) / 2;
4 if ( searchKey == b[ middle ] )
5 return middle;
6 else if ( searchKey < b[ middle ] )
7 return binarySearch( b, searchKey, low, middle - 1 );
8 else if ( searchKey > b[ middle ] )
9 return binarySearch( b, searchKey, middle + 1, high );
10 else
11 return -1;
12}