#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.
3719
How to create a dynamic array of TPoints to draw a polygon?
1796
What are differences between templateurl and template?
827
What is coupling in oop?
989
Why do we use linked lists?
846
Tell me what is applique?
1
If we add regular expressions to a script recorded in QTP,
will it effect the performance of the script?
2159
what is the chiller and working principal
2290
How do I bypass the password on windows 10?
858
What is traits? How it is used in php?
1021
What do you understand by “directoryindex”?
801
What is meant by a Highest Cost Plan?
1009
What is the definition of a line manager ?
5
Why java is interpreted language?
806
Tell us which forms have you most often used in your current and former positions? : insurance health
539