How will inorder, preorder and postorder traversals print
the elements of a tree?
Answer Posted / shital
typedef struct NODE
{
int data;
struct NODE *left,*right;
}node;
void inorder(node * tree)
{
if(tree != NULL)
{
inorder(tree->leftchild);
printf("%d ",tree->data);
inorder(tree->rightchild);
}
}
void postorder(node * tree)
{
if(tree != NULL)
{
postorder(tree->leftchild);
postorder(tree->rightchild);
printf("%d ",tree->data);
}
}
void preorder(node * tree)
{
if(tree != NULL)
{
printf("%d ",tree->data);
preorder(tree->leftchild);
preorder(tree->rightchild);
}
}
Is This Answer Correct ? | 11 Yes | 4 No |
Post New Answer View All Answers
How many types of linked list are there?
How do you determine if a binary tree is height balanced?
Explain what is the data structures used to perform recursion?
What is the use of threaded binary tree?
Why is arraylist used?
Tell me the difference between the character array and a string.
What is non linear structure?
Which sorting is best and why?
Is heap sort stable?
Write a program to sum values of given array.
What is binary tree? Explain its uses.
What is the best data structure and algorithm to implement cache?
Which sorting is best in time complexity?
What is the best sorting technique?
What is an recursive algorithm?