#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.
3761
What is the purpose of c#?
1001
What is line of sight?
934
why electron produce magnetic field when it is in motion?
2149
Was 2000 a leap year?
1055
How to use delete statement in laravel?
744
Beginning with sql server version 7 0, a new enhanced data type nchar was added what type of data is supported with this data type?
1011
What is meant by pass by reference and pass by value in java?
920
type of sale and purchase tax?
1901
How teradata makes sure that there are no duplicate rows being inserted when its a set table?
986
how much cement and sand required for 100sqm of wall plastering in different proportions
2394
What is difference between oracle 9i and oracle 10g?
1834
Can you change array size in java?
964
What is array command?
1182
What is generic method in c#?
945