Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How will inorder, preorder and postorder traversals print
the elements of a tree?

Answers were Sorted based on User's Feedback



How will inorder, preorder and postorder traversals print the elements of a tree?..

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

Post New Answer

More Data Structures Interview Questions

What do you mean by structure property in a heap?

0 Answers  


What are the collision resolution methods?

0 Answers  


What is the difference between dictionary and hashtable?

0 Answers  


What do you mean by 2-3-4 tree?

0 Answers  


On clicking a node in a tree, all the adjacent edges are turned on. Calculate min of clicks such that all the edges are turned on.

0 Answers   Aspiring Minds,


Write the algorithm for converting infix expression to postfix expression?

0 Answers  


What is faster array or arraylist?

0 Answers  


What is a cycle or a circuit?

0 Answers  


What is complete binary tree and almost complete binary tree?

0 Answers  


Define b-tree of order m?

0 Answers  


Why we use linked list?

0 Answers  


Tell me the difference between structure and array?

0 Answers   NIIT,


Categories