Depth First

Recursive

Tree Traversal

https://www.geeksforgeeks.org/tree-traversals-inorder-preorder-and-postorder/

Inorder

(Left, Root, Right) : 4 2 5 1 3

  1. Traverse the left subtree, i.e., call Inorder(left-subtree)
  2. Visit the root.
  3. Traverse the right subtree, i.e., call Inorder(right-subtree)

Preorder

(Root, Left, Right) : 1 2 4 5 3

  1. Visit the root.
  2. Traverse the left subtree, i.e., call Preorder(left-subtree)
  3. Traverse the right subtree, i.e., call Preorder(right-subtree)

Postorder

(Left, Right, Root) : 4 5 2 3 1

  1. Traverse the left subtree, i.e., call Postorder(left-subtree)
  2. Traverse the right subtree, i.e., call Postorder(right-subtree)
  3. Visit the root.