3 ms·
You're missing some of the implementation. From the blog: > A more clever search algorithm can do it with just one bound check in all cases. Tack the desired i
by yifanl 7y ago
You're missing some of the implementation. From the blog:
> A more clever search algorithm can do it with just one bound check in all cases. Tack the desired item on to the end of the array, then start your pointer at the head of the array and do the following in a loop: ...
So you will do exactly one more value check in the case where the element is not in the list, and n - 1 less bounds checks.