Tree traversal
Rooted trees are often used to store information. We use different systematic approaches to visit each vertex of a rooted tree to access data, called traversal algorithms.
Common traversal algorithms:
- Preorder traversal: visit the root, continue traversing subtrees in preorder, from left to right
- Inorder traversal: begin traversing leftmost subtree inorder, then visit root, then continue traversing subtrees in inorder, from left to right
- Postorder traversal: begin traversing leftmost subtree in postorder, then continue traversing subtrees in postorder, from left to right, finally visit root
