"Every node has a story. Master the four essential patterns of node visitation to unlock search, manipulation, and structural analysis."
"Toggle patterns to see the visitation order."
"Visits nodes in ascending order for BSTs. Excellent for sorting."
1function inorder(root) {2 if (!root) return;3 inorder(root.left); // 14 visit(root); // 25 inorder(root.right); // 36}**O(N)**. Every node is visited exactly once.
**O(H)**. Proportional to tree height (Recursion Stack).
"Use to clone a tree. Visit root FIRST so you can create the parent before children."
"Use in BSTs to get sorted data. Every node visits Left (smaller) -> Self -> Right (larger)."
"Use for Deletion. Destroy children before destroying the parent. Safe bottom-up approach."
**Pro-Tip**: Most candidates mix up In-order vs Pre-order under pressure. Draw a 'dot' on the left (Pre), bottom (In), or right (Post) of each node to track visit moments during a path crawl.
"Choose your path based on your task. DFS is recursive and memory-efficient for deep trees; BFS is ideal for shortest-path analysis."