🔹 Preorder Traversal (Root → Left → Right)

Steps:

  1. Visit the root node
  2. Traverse the left subtree
  3. Traverse the right subtree

🔹 Inorder Traversal (Left → Root → Right)

Steps:

  1. Traverse the left subtree
  2. Visit the root node
  3. Traverse the right subtree

Example Tree


         A
       /   \\
      B     C
     / \\   / \\
    D   E F   G
       /     \\
      H       I


🔹 Preorder Traversal (Root → Left → Right)

We visit the node, then traverse the left, then the right.

Steps:

  1. Visit A
  2. Go to left subtree → Visit B
  3. Left of B → D (leaf)