Amazon Interview Question
Software Engineer / Developers// Assume a function height_tree(node *root) will
//return sum of height of left sub tree and height of right sub tree+2;
//I am counting no of edges...
int tree_bredth(node *root)
{
int i,j,k;
i = 0;
j = 0;
k = 0;
if(root = NULL)
return(0);
i = height_tree(root->left);
j = height_tree(root->right);
k = i+j+2;
return(max(k,tree_bredth(root->left),tree_bredth(root->right)))
}
en.wikipedia.org/wiki/Longest_path_problem
- S June 29, 2010