Traversal Methods

There are various different ways you can traverse a BST for different result… The only one I ever found a use for in recency was Inorder Traversal.

We use DFS to run these traversals.

Inorder Traversal

In this traversal method, you visit the left child, the current node, and then the right child.

def inOrder(root):
            if root.left:
                dfs(root.left)
            res.append(root.val)
            if root.right:
                dfs(root.right)