all the option are wrong i have code this
#include<stdlib.h>
using namespace std;
struct node
{
int key;
struct node *left, *right;
};
struct node *newNode(int item)
{
struct node *temp = (struct node *)malloc(sizeof(struct node));
temp->key = item;
temp->left = temp->right = NULL;
return temp;
}
void inorder(struct node *root)
{
if (root != NULL)
{
inorder(root->left);
printf("%d \n", root->key);
inorder(root->right);
}
}
struct node* insert(struct node* node, int key)
{
if (node == NULL) return newNode(key);
if (key < node->key)
node->left = insert(node->left, key);
else if (key > node->key)
node->right = insert(node->right, key);
return node;
}
int DoSomething (node* tree)
{
int value=0;
if (tree != NULL) {
if (tree->left == NULL)
value = 1;
else
value = DoSomething(tree->left);
value = value + DoSomething(tree->right);
}
return(value);
}
int main()
{
struct node *root = NULL;
root = insert(root, 10);
insert(root, 5);
insert(root, 4);
insert(root, 15);
insert(root, 13);
insert(root, 14);
insert(root, 16);
int a=DoSomething (root);
printf("%d",a);
return 0;
}
it is returing 4 but the leaf are 3 only rest all option before are eliminated