Inorder Traversal

void inorder(tree t) 
{
        if(t == NULL)
                return;
        inorder(t->left);
        printf("%d ", t->val);
        inorder(t->right);
}

Preorder Traversal

void preorder(tree t) 
{
        if(t == NULL)
                return;
        printf("%d ", t->val);
        preorder(t->left);
        preorder(t->right);
}

Postorder Traversal

void postorder(tree t) 
{
        if(t == NULL)
                return;
        postorder(t->left);
        postorder(t->right);
        printf("%d ", t->val);
}

Advertisements