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?

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


Please Help Members By Posting Answers For Below Questions

Which language is best for learning data structures and algorithms?

965


Why does hashset use hashmap?

939


Model a data structure for a DFA that takes an event as parameter and performs a desired action.

1105


What is significance of ” * ” ?

1033


How do you sort a map by key?

846


What is the difference between push and pop?

1098


What are the difference between malloc() and calloc()?

1017


Mention the steps to insert data at the starting of a singly linked list?

974


Define an equivalence relation?

1084


How to sort an Array?

904


What is a dequeue?

967


Why would you use a linked list?

928


What are the best data structure courses for gate preparation?

913


Is array faster than arraylist?

954


Can we change the size of an array at run time?

974