4 ms·
This comment is nonsense. Nobody is writing binary searches in their day-to-day jobs, and if they do it's once in a blue moon, not every day. You're using pedal
by adamors 5y ago
This comment is nonsense. Nobody is writing binary searches in their day-to-day jobs, and if they do it's once in a blue moon, not every day. You're using pedals every time you drive.
- sgtnoodle 5y agoYeah, I need to implement a binary search maybe once a year. I had a legit use of a priority queue a couple years ago and I'm still excited about it! I've still never had a professional use for a Trei structure. I tried really hard to make a case for it on a project at Google, but it just didn't make sense vs. slapping down std::map and then drinking a beer.
- mewpmewp2 5y agoIn which case would you actually implement a binary search instead of using an existing library method for that?
- sgtnoodle 5y agoCode running on a microcontroller with very limited RAM, operating on data structures that don't naturally plug into generic algorithm implementations. For example, finding the end of a several GB long append-only log file stored on the raw blocks of an SD card.
- mewpmewp2 5y agoIn these cases did you write it from scratch or were you able to copy paste a working solution? Because most pragmatic to me would be to google for a solution on Stack overflow, see what is upvoted and seems reasonably vetted, then potentially go over the code yourself to see if there's any issues and maybe write few tests to be extra sure. Maybe your use case is too niche though to be able to copy paste though, I'm not sure.
- sgtnoodle 5y agoSure, I'll find some example code on Wikipedia or whatever as a reference. It's faster than deriving it all again from scratch. I don't really copy paste algorithms like that, though. Instead, I review the reference material until I understand the algorithm and any potential edge cases and optimizations that may apply, and then code it up and unit test it.
- otabdeveloper4 5y agoBinary searches should be internalized as part of your life's vocabulary if you're a programmer. You don't use all 10000 words of your native language every day. You don't ride a bike every day. Nevertheless, that's part of you and you don't need to make a conscious effort to remember which way the pedals spin when you ride a bike after a long hiatus.
- swanndev 5y agoI don't think those examples are really applicable here. You don't use all 10000 words, but our brains are evolved to process language and you interact with language everyday. Riding a bike has you engaging in a physical activity which is also something that we're geared to remember. Programming is already pretty unnatural and implementing binary searches and other basic algorithms is really only something you do constantly in the beginning. Over time that "muscle memory" will fade. It's also something that's easy enough to look up and understand in a couple minutes.
- commandlinefan 5y agoThe last time I actually wrote a binary search was in college in 1992. I still remember exactly how to do it... because it's really basic.
- Vvector 5y ago> Nobody is writing binary searches in their day-to-day jobs But in an interview situation, they cannot give you a three week task. Like FizzBuzz, a binary search is a simple task that can be done during an interview. They are not testing your ability to write a binary search. They are testing you on your ability to implement a function, given specific requirements.