How will inorder, preorder and postorder traversals print
the elements of a tree?
Answer Posted / meganathan
void inorder(node * tree)
{
if(tree != NULL)
{
inorder(tree->leftchild);
printf("%d ",tree->data);
inorder(tree->rightchild);
}
else
return;
}
void postorder(node * tree)
{
if(tree != NULL)
{
postorder(tree->leftchild);
postorder(tree->rightchild);
printf("%d ",tree->data);
}
else
return;
}
void preorder(node * tree)
{
if(tree != NULL)
{
printf("%d ",tree->data);
preorder(tree->leftchild);
preorder(tree->rightchild);
}
else
return;
}
Is This Answer Correct ? | 54 Yes | 10 No |
Post New Answer View All Answers
Define non linear data structure.
What is bitonic search?
Is radix sort stable?
Can we insert null in set?
Mention the data structures which are used in graph implementation.
Explain what are the major data structures used in the network data model?
Draw a binary Tree for the expression : A * B - (C + D) * (P / Q)
What is data structure definition?
How many passes are required in bubble sort?
Can we add heterogeneous elements into treemap?
How do you sort a map by key?
What is a dequeue?
How does hashset work internally in java?
What is link list in data structure?
What sorting algorithm does arrays sort use?