Depth-First Tree Traversal in F#

We looked at breath-first tree traversal earlier today, now let’s take a look at depth-first tree traversal as well.

Here, we loop through the tree starting with the root, yield the value for each of the nodes before recursively traversing down all the left branch first and then the right branch.

 

Try it Yourself

 

Links

Leave a Reply

Your email address will not be published.