idea
Traverse a graph going all the way down one node first.
Recursively:
- Call DFS recursively
- Process current node.
Iteratively, use a stack, and array of visited items
- Add root to stack, mark visited
- Till stack is not empty
- Pop element, process.
- Add all adjacent nodes to stack
- Go to 2.
Three orders for trees
- Pre-order: Visit root, then left then right.
- In-order: Visit left, then root, then right
- Post-order: Visit left, right, then root.