There are three typical ways of recursively traversing a binary tree. In each of these, the left sub-trees & right sub-trees are visited recursively and the distinguishing feature is when the element in the root is visited or processed.
Program, Program3 and Program 4 illustrated the inorder, preorder and postorder traversals of a Binary tree.
Program : Inorder traversal of a binary tree
struct NODE *left;
int value; /* can take any data type */
struct NODE *right;
};
inorder(struct NODE *curr)
{
if(curr->left != NULL)
inorder(curr->left);
printf("%d", curr->value);
if(curr->right != NULL)
inorder(curr->right);
}