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 do you mean by Logical Error
Differentiate between arraylist and linkedlist.
What is selection in an algorithm?
Differentiate linear from a nonlinear data structure?
Which is better selection or bubble sort?
Why do we study data structures?
What is difference between hashmap and linkedhashmap?
What is the space complexity of bubble sort?
What is the complexity of arraylist?
What is the complexity of sorting algorithm?
Can you have an arraylist of arrays?
Why do we use hashmap?
What is a stable sorting algorithm?
Differentiate between collection and collections.
What is difference between linear and non linear data structure?