How will inorder, preorder and postorder traversals print
the elements of a tree?
Answers were Sorted based on User's Feedback
Answer / 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 |
Which language is best for learning data structures and algorithms?
What method is used to place a value onto the top of a stack?
What the principle of quick sort and its complexity?
What are the different types of data structures explain briefly?
How many pointers are necessary to implement a simple linked list?
What is the default value of Array?
Why is quicksort unstable?
How do you clear a stack?
What is the use of sorting?
How to print element of Array?
What is difference between arraylist and list?
What type of variable is age?