sum of leaf nodes tree
int sumLeaf(Node* root)
{
if(root==NULL)
return 0;
if(root->left==NULL && root->right==NULL)
return root->data;
return sumLeaf(root->left)+sumLeaf(root->right);
}
{
if(root==NULL)
return 0;
if(root->left==NULL && root->right==NULL)
return root->data;
return sumLeaf(root->left)+sumLeaf(root->right);
}
0 Comments:
Post a Comment