3 ms·
I agree that it's not particularly challenging. As a counterpoint though, a linear search is more basic. It's also often faster than a binary search for small d
by sgtnoodle 5y ago
I agree that it's not particularly challenging. As a counterpoint though, a linear search is more basic. It's also often faster than a binary search for small datasets, and it's easier to prove correct purely by inspection.
Anecdotally, a coworker we hired a couple years ago (and has been doing an awesome job) dusted off her old coding challenge from when she applied, and ran it through a new test suite we've been working on. The suite failed, and it turns out her binary search was buggy...
- AnIdiotOnTheNet 5y ago> As a counterpoint though, a linear search is more basic. It's also often faster than a binary search for small datasets, and it's easier to prove correct purely by inspection. Also for sorted datasets where the most frequently referenced data is at the top.