#include
#include
#include
#include
void insert(struct btreenode **, int);
void inorder(struct btreenode *);
struct btreenode
{
struct btreenode *leftchild;
struct btreenode *rightchild;
int data;
};
main()
{
struct btreenode *bt;
bt=(struct btreenode *)NULL;
int req,i=1,num;
clrscr();
printf("Enter number of nodes");
scanf("%d",&req);
while(i<=req)
{
printf("Enter element");
scanf("%d",&num);
insert(&bt,num);
i++;
}
inorder(bt);
}
void insert(struct btreenode **sr, int num)
{
if(*sr==NULL)
{
*sr=(struct btreenode *)malloc (sizeof(struct btreenode));
(*sr)->leftchild=(struct btreenode *)NULL;
(*sr)->rightchild=(struct btreenode *)NULL;
(*sr)->data=num;
return;
}
else
{
if(num < (*sr)->data)
insert(&(*sr)->leftchild,num);
else
insert(&(*sr)->rightchild,num);
}
return;
}
void inorder(struct btreenode *sr)
{
if(sr!=(struct btreenode *)NULL)
{
inorder(sr->leftchild);
printf("\n %d",sr->data);
inorder(sr->rightchild);
}
else
return;
}
please Modify the given program and add two methods for post
order and pre order traversals.
3778
What is the zooplankton?
383
Tell me what is blouson?
1
How are trace files generated?
1450
Is there any way to prevent a spider from grabbing urls that you want to keep off search engines?
905
How dynamic arrays are created?
914
What is replication difference between wi2k and win2k3
replication?
3489
What is the function of I/O library in C++ ?
1209
What is the role of recordreader in hadoop mapreduce?
740
Describe inheritance and non-inheritance of a derived class?
949
What is dbrm library?
1077
How can I improve throughput in sybase?
936
What do you know about Schlumberger?
1290
One of the difficulties our company has is evaluating
suggestions in a timely manner. What changes would you
make to expedite evaluations?
2158
What do you understand by posting period?
1119