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

Write code for finding depth of tree

Answer Posted / crispin

/*
* Simple tree node representation
*/
struct node_t {
struct node_t *left;
struct note_t *right;
};

/*
* Return the maximum depth of the tree given a pointer
* to its root node.
*/
unsigned int
tree_depth (node_t *root)
{
return (NULL == root) ? 0 :
MAX(tree_depth(root->left, root->right)+1);
}

Is This Answer Correct ?    3 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the characteristics of arrays in c?

996


#include int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

1684


What is the difference between procedural and declarative language?

1104


Which built-in library function can be used to match a patter from the string?

1251


How can I determine whether a machines byte order is big-endian or little-endian?

1016


Where static variables are stored in memory in c?

957


swap 2 numbers without using third variable?

1086


what do you mean by inline function in C?

1015


What is size of union in c?

988


In C programming, what command or code can be used to determine if a number of odd or even?

1003


Explain goto?

1102


code for quick sort?

1989


How can I find the modification date and time of a file?

1044


hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm

1981


What is the difference between new and malloc functions?

1064