How fast can you make linear search?
- by Mark Probst
I'm looking to optimize this linear search:
static int
linear (const int *arr, int n, int key)
{
int i = 0;
while (i < n) {
if (arr [i] >= key)
break;
++i;
}
return i;
}
The array is sorted and the function is supposed to return the index of the first…