3 ms·
> Do slices give access to their underlying offset? They don't have to, you already have `middle` available, they can just return Some(middle)
by tsimionescu 6y ago
> Do slices give access to their underlying offset?
They don't have to, you already have `middle` available, they can just return Some(middle)
- klyrs 6y agoNo, 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.
- tsimionescu 6y agoOops, you're absolutely right. I completely forgot that the array variable was being modified itself.