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
What is array and structure?
Explain the principle of quicksort. What is its complexity?
Is it possible to store null key and null values in a hashmap?
What is a singletonlist?
What is a priority queue?
Explain what are the methods available in storing sequential files ?
Explain about the different lists available in the collection?
How can we delete any specific node from the linked list?
What are the types of collection?
Which is better bubble sort or selection sort?
What type of variable is age?
What is data structure and its operations?
Explain the implementation of an AVL tree and Binary tree.
What does quick sort do?
Is radix sort stable?