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 |
What is a binary search tree? Explain with example?
What are basic algorithms?
What is data type in data structure?
What is the difference between binary tree and binary search tree?
Write programs for Bubble Sort, Quick sort
Why is hashset not ordered?
What is a hash index?
applications of stacks and their uses?
Are linked lists considered linear or non-linear data structure?
How to create an Array?
What is selection sort with example?
What is vector and types of vector?