0
2.6kviews
Traverse the binary tree into preorder, inorder and postorder by giving its algorithm.
1 Answer
written 8.6 years ago by |
The preorder tree traversal’s algorithm is:-
Visit the node.
Traverse the left subtree.
Traverse the right subtree.
The inorder tree traversal’s algorithm is:-
Traverse the left subtree
Visit the node.
Traverse the right subtree.
The postorder tree traversal’s algorithm is:-
Traverse the left subtree.
Traverse the right subtree.
Visit the node.
The preorder traversal is: A-B-D-E-H-I-C-F-G
The inorder traversal is: D-B-H-I-E-A-C-G-F
The postorder traversal is: D-I-H-E-B-G-F-C