I am working on binary search code on C what will StringCompare code be so I cou
ID: 3639994 • Letter: I
Question
I am working on binary search code on C
what will StringCompare code be so I could continue
int FindStringInSortArray(string key, string array[], int n)
{
return (BinarySearch(key, array, 0, n-1));
}
static int BinarySearch(string key, string array[], int low, int high)
{
int mid, cmp;
if (low > high)
return (-1);
mid = (low+high)/2;
cmp = StringCompare(key, array[mid])
if (cmp == 0)
return (mid);
if (cmp < 0)
{
BinarySearch(key, array, low, mid - 1);
}
else
{
BinarySearch(key, array, mid + 1, high);
}
}
Explanation / Answer
if 2 strings s1=s2 then it returns 0 if 2 strings s10Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.