Recursion

Traversal Order

Tree DFS

Without writing code, determine the preorder traversal, inorder traversal, and postorder traversal of the following tree.

Hint: is there a fast way to do this?

Here's a trick to finding the preorder traversal: draw a flag to the left of every node and trace through a path, going counterclockwise.

You get that the preorder traversal order is [A, B, D, E, F, G, C]

You can do something similar for inorder and postorder traversals,

Inorder traversal = [D, B, F, E, G, A, C]

Postorder traversal = [D, F, G, E, B, C, A]

Why this trick works (optional):

Mark as Completed:
Submits:
test
Imports:
TreeNode
Test your code to get an output here!