You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
what about something like:
int bleh = h->size;
do{
bleh/=2;
if (v[j] < s[i])
{
j+=bleh;
}
else if (v[j] > s[i])
{
j-=bleh;
}
else
{
//got hit
}
}while (bleh>1);
divide and conquer scanning instead of linear?
/* Even when h->size is large, linear scan provides good
* performances compared to other approaches that are in theory
* more sounding, like performing a binary search. */
for (j = 0; j < h->size; j++) {
if (v[j] == s[i]) break;
}
The text was updated successfully, but these errors were encountered:
I tried and it was slower, but actually later I found pathological cases where it could help. What to do IMHO is to test it a lot and find the right threshold when to switch to binary search.
what about something like:
int bleh = h->size;
do{
bleh/=2;
if (v[j] < s[i])
{
j+=bleh;
}
else if (v[j] > s[i])
{
j-=bleh;
}
else
{
//got hit
}
}while (bleh>1);
divide and conquer scanning instead of linear?
The text was updated successfully, but these errors were encountered: