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 |
When new data are to be inserted into a data structure?
What is the need for extendible hashing?
Where is insertion sort used?
Does linked list allow duplicates?
Does hashmap maintain insertion order?
What is meant by binary tree?
How to fill element (initialize at once) in an array?
What are the advantages and disadvantages of linked list?
Why is quicksort better than mergesort?
Define in brief an array.
Which collection is used for sort?
Is it possible to make an array volatile in java?