How will inorder, preorder and postorder traversals print
the elements of a tree?
Answer Posted / narendra sharma
struct tree
{
int data;
struct NODE, *left, *right;
}
typedef struct node;
void inorder(node * tree)
{
if(root!=null)
inorder(tree->leftchild);
printf("%d",tree->data);
inorder(tree->rightchild);
}
void preorder(node * tree)
{
if(root!=null)
printf("%d",tree->data);
preorder(((tree->leftchild);
preorder(((tree->rightchild);
}
void postorder(node * tree)
{
if(root!=null)
postorder(tree->leftchild);
postorder(tree->rightchild);
printf("%d",tree->data);
}
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
What is meant by balanced binary tree?
What is adt example?
Which sorting algorithm is used in collections sort?
Can you please explain the difference between string and an array?
Which is best array or linked list?
What is stable sorting method?
What is the difference between data type and data structure?
How do you sort large data?
What is data structure and its classification?
Write a code for dynamic allocation of array.
List some applications of queue data structure.
Explain the Array
What is a weighted graph?
What is minimum depth of binary tree?
Tell me what is quick sort?