i have function which finds a number in a table:
int find(int arrf[], int len, int seek)
{
for (int i = 0; i < len; ++i)
if (arrf[i] == seek)
return i;
return -1;
}
Is there a faster way to do this?
i have function which finds a number in a table:
int find(int arrf[], int len, int seek)
{
for (int i = 0; i < len; ++i)
if (arrf[i] == seek)
return i;
return -1;
}
Is there a faster way to do this?
For linear search two optimizations come to mind:
Intel Parallel STL can do both optimizations for you.