Professional Documents
Culture Documents
● A→B→D→E→C→F→G ● A, B, D, G, H, L, E, C, F, I, J, and K
Postorder Traversal
● Until all nodes of the tree are not visited
● Step 1: Traverse the left subtree recursively, call Postorder (left subtree)
● Step 2: Traverse the right subtree recursively, call Postorder (right sub tree)
● Step 3: Visit the root node.
Postorder Traversal
● D→E→B→F→G→C→A ● G, L, H, D, E, B, I, K, J, F, C, and A
Inorder Traversal
● Until all nodes of the tree are not visited
● Step 1 - Traverse the left subtree recursively, call Inorder (left sub tree)
● Step 2 - Visit the root node.
● Step 3 - Traverse the right subtree recursively, call Inorder (right sub tree)
Inorder Traversal
● D→B→E→A→F→C→G ● G, D, H, L, B, E, A, C, I, F, K, and J
Example
● Post Order: D B G E F C A
● In Order: D B A E G C F
● Pre Order: A B D C E G F
Traversal Conversion (BST)
● Pre Order: 12 8 6 2 7 9 10 16 15 19 17 20
● In Order: Sorted Data
● Post: 2 7 6 10 9 8 15 17 20 19 16 12
● Post Order: 10 9 23 22 27 25 15 50 95 60 40 29
● In Order: Sorted Data
● Pre Order: 29 15 9 10 25 22 23 27 40 60 50 95
References