int diameterofnode(node*root){
if(root == NULL)
return 0 ;
int ls = diameterofnode(root->left);
int rs = diameterofnode(root->right);
return max(ls,rs)+1;
}
int main()
{
node*root = build_tree();
int a1 = diameterofnode(root->left);
int a2 = diameterofnode(root->right);
cout << a1 + a2 << endl ;
}
will this code work in every test case?