How will inorder, preorder and postorder traversals print
the elements of a tree?
Answer Posted / soma gidugu
void inorder(node * root)
{
if(root!= NULL)
{
inorder(root->leftchild);
printf("%d ",root->data);
inorder(root->rightchild);
}
else
return;
}
void postorder(node * root)
{
if(root!= NULL)
{
postorder(root->leftchild);
postorder(root->rightchild);
printf("%d ",root->data);
}
else
return;
}
void preorder(node * root)
{
if(root!= NULL)
{
printf("%d ",root->data);
preorder(root->leftchild);
preorder(root->rightchild);
}
else
return;
}
| Is This Answer Correct ? | 13 Yes | 7 No |
Post New Answer View All Answers
What differences exist between hashmap and hashtable?
Why null is allowed in hashmap?
Differentiate stack from array?
Define circular list?
What is difference between array and string?
Briefly explain recursive algorithm 50 how do you search for a target key in a linked list?
What are data structures in programming?
How do signed and unsigned numbers affect memory?
Tell us the difference between merge and quick sort. Which one would you prefer and why?
Define quadratic probing?
Can map contain duplicate keys?
In what order the elements of a hashset are retrieved?
Does treeset allow null?
How does shell sort work?
What is stack and queue in data structure?