How will inorder, preorder and postorder traversals print
the elements of a tree?
Answer Posted / 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 |
Post New Answer View All Answers
What is the height of an empty tree?
Is radix sort faster than quicksort?
Devise a program to sort an array using bubble sort.
How does insertion sort works?
What are the types of array operations?
Explain the implementation of an AVL tree and Binary tree.
Write the recursive c function to count the number of nodes present in a binary tree.
What are the advantages of merge sort?
Does hashmap maintain insertion order?
Describe tree database.
What do you mean by shortest path?
What is the use of hashtable?
What are linked lists used for?
If you have to store one lakh objects, what will be a better option- a hash map or an array list?
What is a string array?