3 ms·
Yeah, 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 stil
by sgtnoodle 5y ago
Yeah, 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.