2 ms·
> For example, the code for traversing a tree in any order is implemented using recursion, but this is not what production code would do, I think this is much
by tylerhou 4y ago
> For example, the code for traversing a tree in any order is implemented using recursion, but this is not what production code would do,
I think this is much too strong of a generalization. For small trees, a recursive traversal is clearer & easier to modify, and I would prefer to ship a recursive traversal vs. an iterative one.
In fact, part of my job at Google was optimizing a particular (recursive) tree traversal in Search. Every time you search on Google, that traversal happens many thousands of times behind the scenes :).