1. ## binary tree...

I tried out this dynamic creation of binary tree where in the user has the option of choosing whether the left child or the right child should be added or not. I just tried it out for the root and creating one left child and one right child. Now the thing which is puzzling me is that though this works fine for this case will this work fine for any number of left children and right children as well. I have used recursion for the same and after going to a certain depth i seem to get lost of where in i am in the loop. So i just tried it out for one case of having a root and one left child and one right child and it worked fine . So can i extend this to general case as well where in i can have n left child and n right child?

[insert]
Code:
```#include <stdio.h>
#include <stdlib.h>

void display(struct node * root);
void buildtree(struct node **root);

struct node
{

struct node * left;
int data;
struct node * right;
};

int main(void)
{
struct node *root;
int data;

root = (struct node *) malloc(sizeof(struct node));
printf("\n Enter the data for the root");
scanf("\n %d", &data);
root->data = data;
buildtree(&root);

printf("\n The tree that you built is");
display(root);

return 0;
}

void display(struct node * root)
{
if(root != NULL)
{
display(root->left);
printf("\n%d", root->data);
display(root->right);
}
}

void buildtree(struct node **root)
{

char ch;
int data = 0;
struct node *temp = NULL;
printf("\n Do you want to add left child");
scanf("\n%c", &ch);
if(ch == 'y' || ch == 'Y')
{
temp = (struct node *) malloc(sizeof(struct node));
(*root)->left = temp;
scanf("\n %d", &data);
temp->data = data;
buildtree(&temp);
}
else
{
(*root)->left = NULL;
}

printf("\n Do you want to add right child");
scanf("\n%c", &ch);
if(ch == 'y' || ch == 'Y')
{
temp = (struct node *) malloc(sizeof(struct node));
(*root)->right = temp;
scanf("\n %d", &data);
temp->data = data;
buildtree(&temp);
}
else
{
(*root)->right = NULL;
}

};```

2. Are you trying to create a balanced tree ie where no. of left nodes == no. of right nodes or is it going to be asymmetric.

3. It can be asymmetric as well (depends on the user how many left children and right children he wants to create)

4. Looking at your program, I think it'll work perfectly alright for any binary tree.