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 are binary search and fibonacci search?
How do you declare An array of three pointers to chars
Why do we use linked lists?
Can you use Bubble Sort To sort the number of elements.
What’s the difference between enumeration and iterator interfaces?
State the difference between queues and linked lists?
Define primary data structures?
What are the advantages of sorting?
Can arraylist store objects?
Can the double-checked locking fail on a single processor system?
What is data structure explain different types of data structures with examples?
Can you list out the areas in which data structures are applied extensively?
What's the difference between a hashtable and a hashmap?
Is data structure a data type?
What is the difference between collection and collections?