suppose this is the binary search tree
http://upload.wikimedia.org/wikipedi...earch_tree.svg
code for post order transversal
Code:
void preorder(struct tree *rt)
{
if(rt==NULL)
{
return;
}
printf("%d ",rt->info);
preorder(rt->lchild);
preorder(rt->rchild);
}
It will print 8 then 3 then 1
after printing 1 this statement will execute
preorder(rt->lchild); because the left of node which contains 1 is NULL so in this recursive function preorder(rt->lchild); null will be passed. then root will also become NULL thats why this if statement will execute
Code:
if(rt==NULL)
{
return;
}
Now what will happen after returning in which statement control will be passed ?