#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.
3830
What is the difference between serializable and parcelable?
971
What do you understand by intent locks?
1063
what is test case management?explain in brief.
2142
Why is there extra space before or after my table?
980
Explain the operation of 1φ sinusoidal ac voltage controller?
1099
Explain about Obj-Open method?
555
How do you think you can make a contribution to Ralph Lauren?
1222
What is excel and when would I use it?
706
If the address bus id 20bits.then the memory space is ?
1066
What are all stats classes in the java api package available?
601
How do you choose the hosting for wcf internet service?
882
Re: what are the Issue that we face in Gl,PO and AP while
Supporting
2309
What are the six rights of merchandising?
5
What is clustered index in sql?
1101