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
- Breath-First Tree Traversal
- DotNetFiddle snippet
- All my Project Euler solutions in F#
- All my Advent of Code solutions in F#