4 ms·
They are trivial to implement, but not desirable if you want your project to integrate with the company's existing codebase and be able to draw on a large base
by jcrites 5y ago
They are trivial to implement, but not desirable if you want your project to integrate with the company's existing codebase and be able to draw on a large base of preexisting algorithms.
A company like Google/Facebook(Meta)/Amazon doesn't want many redundant copies of binary tree implementations per language in their code base. In general they'd want one implementation with a suite of algorithms that can operate on it.
Maybe if your implementation is very specific to the task at hand it might make sense; otherwise I'd expect to use a binary tree via something like a sorted container interface. For example, in Java, something like java.util.TreeMap [1], which I understand is implemented as a binary tree.
Unless you were building a compiler or data store or something very specific and optimized, I see the need for building one as unlikely.
[1] https://docs.oracle.com/javase/7/docs/api/java/util/TreeMap.html https://docs.oracle.com/javase/7/docs/api/java/util/TreeMap....
- WalterBright 5y agoOn the other hand, I also like to make my modules standalone, and not have 20-30 dependencies. I agree with you about things like "convert this string to a number", where it's too easy to get wrong (like not handling overflow) or be inefficient. But binary trees (and linked lists), like I said, are so trivial it is just not worth the bother.