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
Can we change load factor of hashmap?
What are the major data structures used in the following areas : network data model & hierarchical data model?
What is dequeue operation?
What is queue example?
What do you mean by the term “percolate up”?
What is an example of an algorithm?
Define leaves?
What are the advantages of selecetion sort?
Write a program to sum values of given array.
What is quick sort example?
Which sorting is best and why?
Define right-in threaded tree?
Why do we use collections?
How many times is merge sort called?
What are hash tables good for?