Tree Traversal Techniques
Traversal is the method of processing each and every node in the Binary Search Tree exactly once in a systematic manner.
There are three different types of tree traversal.
(1) Preorder Traversal
(2) In order Traversal
(3) Post order Traversal
There are three different types of tree traversal.
(1) Preorder Traversal
(2) In order Traversal
(3) Post order Traversal
PreOrder Traversal
Steps for Preorder Traversal:
(1) Process the root node first.
(2) Traverse the left sub tree in preorder.
(3) Traverse the right sub tree in preorder.
(1) Process the root node first.
(2) Traverse the left sub tree in preorder.
(3) Traverse the right sub tree in preorder.
InOrder Traversal
Steps for Inorder Traversal:
(1) Traverse the left sub tree in inorder.
(2) Process the root node.
(3) Traverse the right sub tree in inorder.
(1) Traverse the left sub tree in inorder.
(2) Process the root node.
(3) Traverse the right sub tree in inorder.
PostOrder Traversal
Steps for PostOrder Traversal:
(1) Traverse the left sub tree in Post order.
(2) Traverse the right sub tree in Post order.
(3) Process the root node.
(1) Traverse the left sub tree in Post order.
(2) Traverse the right sub tree in Post order.
(3) Process the root node.
Now Consider Following Example
Comments
Post a Comment
Thanks for comment. We will get back to you soon...