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.
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.
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.
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.
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.