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

void inorder(node * root)
{
if(root!= NULL)
{
inorder(root->leftchild);
printf("%d ",root->data);
inorder(root->rightchild);
}
else
return;

}

void postorder(node * root)
{
if(root!= NULL)
{
postorder(root->leftchild);
postorder(root->rightchild);
printf("%d ",root->data);
}
else
return;
}

void preorder(node * root)
{
if(root!= NULL)
{
printf("%d ",root->data);
preorder(root->leftchild);
preorder(root->rightchild);
}
else
return;

}

Is This Answer Correct ?    13 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can list contain null values?

820


Which list does not allow duplicates?

824


Is it legal to initialize list like this?

895


Explain binary representation?

814


What are the different types of sorting in data structure?

953


Why do we use collections?

837


Is array size dynamic or fixed?

899


What is the space complexity of bubble sort?

902


What happens if we put a key object in a hashmap which exists?

890


Explain the principle of quicksort. What is its complexity?

992


Can arraylist contain duplicates?

799


How many parts are there in a declaration statement using data structures?

909


What are basic algorithms?

852


What is time complexity of hashmap?

988


List out the advantages of using a linked list?

806