Patterns
Tree Traversal
Tree traversal is the process of visiting each node in a tree data structure. There are two main categories:
- Breadth First Search (BFS) - Visit nodes level by level
- Depth First Search (DFS) - Visit nodes by exploring as deep as possible before backtracking
- Preorder: root → left → right
- Inorder: left → root → right
- Postorder: left → right → root