3 ms·
Tutorials such as this one seem geared more towards college DSA courses rather than actual production code. For example, the code for traversing a tree in any
by photochemsyn 4y ago
Tutorials such as this one seem geared more towards college DSA courses rather than actual production code. For example, the code for traversing a tree in any order is implemented using recursion, but this is not what production code would do, as for any large amount of data the stack would be exhausted as recursive depth limits are exceeded. Thus, real-world code always requires the creation of a dynamically allocated stack or queue on the heap to store the values at each node.
I don't know if there are similar issues with say, the presenation of hash tables, but it does cause a certain lack of confidence. This kind of gap between academic presentation of concepts and real-world production approaches is fairly common - but why not always teach the latter, I wonder?
I imagine 'baby steps' is the argument, but it could also be called teaching bad practices. Incidentally, ChatGPT continues to astound:
> "What would a code snippet for traversing a binary search tree in in-order in Javascript using a dynamically allocated heap approach look like?"
- 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 :).