How will inorder, preorder and postorder traversals print
the elements of a tree?
Answer Posted / shital
typedef struct NODE
{
int data;
struct NODE *left,*right;
}node;
void inorder(node * tree)
{
if(tree != NULL)
{
inorder(tree->leftchild);
printf("%d ",tree->data);
inorder(tree->rightchild);
}
}
void postorder(node * tree)
{
if(tree != NULL)
{
postorder(tree->leftchild);
postorder(tree->rightchild);
printf("%d ",tree->data);
}
}
void preorder(node * tree)
{
if(tree != NULL)
{
printf("%d ",tree->data);
preorder(tree->leftchild);
preorder(tree->rightchild);
}
}
| Is This Answer Correct ? | 11 Yes | 4 No |
Post New Answer View All Answers
Define a relation?
What are basic algorithms?
Can we insert null in hashset?
What are the different types of collections?
Which data structure is applied when dealing with a recursive function?
List the types of tree.
What is hashing with example?
Can you override methods of arraylist?
Mention the data structures which are used in graph implementation.
Can hashset contain duplicates?
Explain binary tree traversals?
Is binary tree a bst?
What is peek in stack?
Define separate chaining?
Define quadratic probing?