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 |
Define internal nodes?
Which data structures are applied when dealing with a recursive function?
What is the difference between hashmap and linkedhashmap?
Does stringutils isempty check for null?
What is the complexity of arraylist?
Can arraylist be null?
Can we remove element from arraylist while iterating?
Are linked lists useful?
What are the drawbacks of array implementation of queue?
What is the method to find the complexity of an algorithm?
Which language is best to learn data structures?
What is an externalizable interface?