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 |
What do you mean by structure property in a heap?
What are the collision resolution methods?
What is the difference between dictionary and hashtable?
What do you mean by 2-3-4 tree?
On clicking a node in a tree, all the adjacent edges are turned on. Calculate min of clicks such that all the edges are turned on.
Write the algorithm for converting infix expression to postfix expression?
What is faster array or arraylist?
What is a cycle or a circuit?
What is complete binary tree and almost complete binary tree?
Define b-tree of order m?
Why we use linked list?
Tell me the difference between structure and array?