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 / 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


Please Help Members By Posting Answers For Below Questions

What do you mean by Syntax Error

1004


Give the example of validating the parenthesis of expression using stack.

985


Is quicksort recursive?

915


What are the advantages of linked list over array (static data structure)?

1283


What is the use of hashtable?

835


What is difference between array and string?

941


What do you mean by union-by-weight?

951


What do you mean by probing?

909


What are the applications of priority queues?

961


What is sequential search?

898


Define shortest path?

968


Is unordered_map a hash table?

823


Write an algorithm to show various operations on ordered list and arrays

888


What is data structure and its types?

856


Does the minimal spanning tree of a graph give the shortest distance between any 2 specified nodes?

910