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

What is the height of an empty tree?

905


Is radix sort faster than quicksort?

826


Devise a program to sort an array using bubble sort.

957


How does insertion sort works?

823


What are the types of array operations?

861


Explain the implementation of an AVL tree and Binary tree.

896


Write the recursive c function to count the number of nodes present in a binary tree.

829


What are the advantages of merge sort?

789


Does hashmap maintain insertion order?

872


Describe tree database.

839


What do you mean by shortest path?

1007


What is the use of hashtable?

830


What are linked lists used for?

907


If you have to store one lakh objects, what will be a better option- a hash map or an array list?

1160


What is a string array?

867