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 |
Give a real time example of stack
What is queue example?
Evaluate the following prefix expression " ++ 26 + - 1324"
24 Answers College School Exams Tests, Patni,
If you are using c language to implement the heterogeneous linked list, explain what pointer type will you use?
What is collision in data structure?
Mention the advantages of representing stacks using linked lists than arrays?
how to find the number of possible tree in the given tree.
12 Answers Persistent, TCS, Wipro,
How does the bubble sort work?
Define balancing condition for AVL Tree.
Can constructor be static?
What is the difference between a stack and an array?
What are arrays used for?