C-program to count the leaves in a tree

12. Write a C program to count the number of leaves in a tree

struct binarysearchtree{
int data;
struct binarysearchtree* left;
struct binarysearchtree* right;
typedef struct binarysearchtree* tree;

int count_leaves(tree T)
return 0;
else if(T->left==NULL && T->right==NULL)
return 1;
return count_leaves(T->left)+count_leaves(T->right);

Click Here For More Questions

No comments:

Post a Comment