void loadArray( int a[], int &cnt, ifstream &infile )
{
while( cnt < MAX && infile >> a[cnt] )
cnt++;
infile.close(); // Done reading. Close it
}
void printArray( int a[], int cnt )
{
for ( int i=0 ; i<cnt ; i++ )
cout << a[i] << " ";
cout << endl;
}
int bsearch( int a[], int cnt, int target )
{
int lo=0, hi=cnt-1;
while ( lo <= hi )
{
int mid = (lo+hi)/2;
/* if the target # is here at the mid slot
then just return mid. we are done :)
otherwise if target is > a[mid]
set lo to mid+1
otherwise it must be true that target < a[mid]
so, set hi to mid -1
*/
}
// if you make it to here and never returned out of the loop
// then the number must not be in the array
// return NOT_FOUND