PDA

View Full Version : Binary Search How to have just number argument


Hamed
05-27-2009, 07:50 PM
I know this code for binary search

int search(int a[], int key, int low, int high) {
if (high < low) {
return NOT_FOUND;
}
int mid = (low + high) / 2;
if (key>a[mid]) {
return searchName(a, key,low, mid-1);
} else if (key<a[mid]) {
return searchName(a, key,mid+1, high);
} else {
return EXIT_SUCCESS;
}
return ERROR_SEARCH;
}

Now I want to make recursive one which just need
int search(char *dict, char *name,int length,int compChars)
and length is number element in array.
please help me.

AboutComputer Forums
06-09-2009, 08:24 AM
Hi hamed i found this - http://www.aboutcomputer.org/showthread.php?t=21 hope this might help you out.