The Semantics of Depth-First Tree Traversal

Reading time: 1 minute

I learn most effectively by either visualization, verbal explanation (e.g. to the proverbial duck) or by understanding where the semantics or even etymology of how a concept, idea or theory is described. The following is example of the latter.

A week or so ago, the obvious way to semantically distinguish between different types of depth-first tree traversals suddenly (and finally!) crystallized in my mind: pre-order, in-order and post-order. The parts in bold, i.e. the prefix that semantically differentiates the approaches, refers to the relative position of the root node. Doh! Note that here the left child node comes before the right child node.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.