mattkr
asked on
Search an array
What is the quickest way to seatch an array that is already sorted? ANd how do I do it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Uhmm... Why not use bsearch() from the standard run-time C library?
int max=(sizeof(array)/sizeof(
while( min < max ){
int x = (max+min)/2;
if( array[x] < target ){
min = x+1;
}else if( array[x] > target ){
max = x-1;
}else{
printf("array[%d] = %d\n",x,array[x]);
max=min=x;
}
}