3 ms·
I've used "Modified Preorder Tree Traversal" as a method for storing tree-structured/hierarchical data a few times. (Threaded 'forums', 'Folder'-type management
by ourcat 7y ago
I've used "Modified Preorder Tree Traversal" as a method for storing tree-structured/hierarchical data a few times. (Threaded 'forums', 'Folder'-type management/curation of RSS feeds (to churn out OPML, for example)
Walking the tree like this provides some mind-bogglingly easy ways of presenting 'branches/nodes' of the tree and their descendants, as well as the pathway to a node.
It required each item to have a 'left' and 'right' value, along with efficiently (as possible) updating those values when the structure changes.
I've always thought there must be many more ways this could be used these days, for things we haven't thought of yet.
- taeric 7y agoIn reading Knuth's volume one a few years ago, I was surprised by the threaded tree structure he presents. Gives easy ways to do stack free traversal of a tree. I confess there is no good reason this surprised me. But it did. I share your thought that there are probably more uses for this than I've seen. I'll modify the thought and say I just assume they are getting used and I don't know if the doors directly. (I'll note that you can view a DOM tree as threaded, do I have seen stack free traversal used. Just not often.)