|
|
|
|
|
by praptak
671 days ago
|
|
The original application of the sentinel technique makes linear search faster. Looking for 42 in a table of integers? Put 42 after the last element (obviously you need n+1 elements allocated) and your loop does not need to check array bounds, only checking for a[i]==42 is now guaranteed to stop and not read past the array bounds. (obviously it doesn't work if multiple threads search the same table for different values) |
|