Learn How Tree Traversal Method Works

PreOrder Traversal Algorithm



Step 1: If ROOT = NULL then
            Write “Tree is Empty”
            Else
            Write ROOT->INFO
Step 2: If ROOT->LPTR ≠ NULL then
            Call PREORDER (ROOT->LPTR)
Step 3: If ROOT->RPTR ≠ NULL then
            Call PREORDER (ROOT->RPTR)


     

InOrder Traversal Algorithm



Step 1: If ROOT = NULL then
            Write “Tree is Empty”
Step 2: If ROOT->LPTR ≠ NULL then
            Call INORDER (ROOT->LPTR)
Step 3: Write ROOT->INFO
Step 4: If ROOT->RPTR ≠ NULL then
            Call INORDER (ROOT->RPTR)


PostOrder Traversal Algorithm



Step 1: If ROOT = NULL then
            Write “Tree is Empty”
Step 2: If ROOT->LPTR ≠ NULL then
            Call POSTORDER (ROOT->LPTR)
Step 3: If ROOT->RPTR ≠ NULL then
            Call POSTORDER (ROOT->RPTR)
Step 4: Write ROOT->INFO

Download Projects


Download Programs