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

Explain what is the most efficient way to store flag values?

702


Describe dynamic data structure in c programming language?

609


What is integer constants?

626


What is a global variable in c?

592


Can a function be forced to be inline? Also, give a comparison between inline function and the C macro?

661






Can we assign integer value to char in c?

619


What is n in c?

577


cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration

640


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

1895


What is the advantage of c?

613


Why can’t constant values be used to define an array’s initial size?

838


Is that possible to add pointers to each other?

907


Write a program with dynamically allocation of variable.

607


difference between object file and executable file

6100


List out few of the applications that make use of Multilinked Structures?

1310