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
Does linkedhashset allow duplicates?
Define balanced trees?
Is quicksort greedy algorithm?
What does simulation of queues mean?
What is entryset method in map?
Differentiate between hashset and hashmap.
Is array a data structure?
Explain how is linked list implemented?
Explain the internal working of a hash map?
What is a node in it?
What is the application of queue?
What is the best time complexity of bubble sort?
Why would you use a linked list?
Write the advantage of separate chaining?
What is adt in data structure?