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 store null in arraylist?
In what scenario, binary search can be used?
Is merge sort better than quick?
Is hashset a collection?
Is null allowed in list?
Is it possible to insert different type of elements in a stack? How?
Calculate the efficiency of sequential search?
What is the order of selection sort?
Is there any difference between int[] a and int a[]?
What is garbage collection in data structure?
What are the advantages of data structure?
Describe the degree term in a tree.
What is a treemap chart?
What does a bubble chart show?
Can you change size of array once created?