Re:Binary Search Reconsidered (2018)
by klyrs on Friday December 25, 2020 @04:40PM
(#25539252)
No, middle is an index into a slice with an arbitrary offset. Unless (with probability ≈ 0.5^log(n)) you've picked the lower half every time before finding the element, that is not the correct index.
[ Parent
| on HN ]
Re:Binary Search Reconsidered (2018)
by tsimionescu on Saturday December 26, 2020 @01:16AM
(#25541809)
Oops, you're absolutely right. I completely forgot that the array variable was being modified itself.