-
Notifications
You must be signed in to change notification settings - Fork 0
Tree Traversal
DhruvP-23 edited this page Apr 16, 2024
·
8 revisions
Vertical line | "root middle (in)"
Algorithm Inorder(tree)
- Traverse the left subtree, i.e., call Inorder(left->subtree)
- Visit the root.
- Traverse the right subtree, i.e., call Inorder(right->subtree)
Diagonal line | "root 1st (pre)"
Algorithm Preorder(tree)
- Visit the root.
- Traverse the left subtree, i.e., call Preorder(left->subtree)
- Traverse the right subtree, i.e., call Preorder(right->subtree)
Left, Right, Parent | "root last (post)"
Algorithm Postorder(tree)
- Traverse the left subtree, i.e., call Postorder(left->subtree)
- Traverse the right subtree, i.e., call Postorder(right->subtree)
- Visit the root
