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

List some of the static data structures in C?

952


What is volatile variable in c?

850


What do you mean by recursion in c?

849


Explain how can I read and write comma-delimited text?

916


how logic is used

1686


What is wild pointer in c?

795


What is the difference between array and pointer in c?

792


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

1326


What is string concatenation in c?

763


What is n in c?

788


What is the use of the function in c?

779


Is array name a pointer?

801


What is oops c?

839


Is c is a low level language?

783


Explain a pre-processor and its advantages.

833