🔹 Preorder Traversal (Root → Left → Right)
Steps:
- Visit the root node
- Traverse the left subtree
- Traverse the right subtree
🔹 Inorder Traversal (Left → Root → Right)
Steps:
- Traverse the left subtree
- Visit the root node
- 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:
- Visit
A
- Go to left subtree → Visit
B
- Left of B →
D (leaf)