O'Reilly logo

Learning F# Functional Data Structures and Algorithms by Adnan Masood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Navigating the tree

Consider the tree in the following figure. Our objective is to traverse the tree, that is, iterate through the nodes. There are several different approaches to do so but some of the most common ones are in-order, post-order, and pre-order traversal:

Navigating the tree

In the in-order traversal, we start from the root node and traverse to left subtree, and then we visit the root node and then traverse to right subtree as seen in the following. The nodes are traversed in this order: A, B, C, D, …, H, I:

Navigating the tree

An in-order traversal algorithm can be implemented ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required