preorder traversal (recursive)
void preorder(NODE *Node)
printf("%c ", Node->data);
In the above program fragment even though the statement 'preorder(Node->leftchild)'
occurs before the statement 'preorder(Node->rightchild)' the actual execution of the program shows that after printing the head node with the help of 'printf()', program control goes to 'preorder(Node->rightchild)'.
It seems that the issue here is related to SYSTEM STACK, but I am unable to say anything about it. Please try to explain in detail how such thing involving seemingly non-sequential execution comes into effect.
Also let me know about similar things occuring in postorder traversal of a binary tree.
Re: preorder traversal (recursive)
Without the rest of the program, the data given and the output received, it's impossible to say. From the code given, the second printf *willl* be of Node->leftchild->data, so it's impossible to say why you think it's rightchild.
|All times are GMT +5.5. The time now is 05:27.|