#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.
3773
hi, this is raju,iam studying b.tech 2nd year,iam want know
about group1 and group2 details, and we can studying
without going to any instutions? please help me.
1957
What is difference between pop and oop?
1176
How is class defined?
1151
What is oops in simple words?
1109
What is balance factor?
1091
which feature are not hold visual basic of oop?
2199
Write A Program to find the ambiguities in Multiple
Inheritance? How are they
resolved.(Virtual Functions)
4157
What is the problem with multiple inheritance?
1177
What is stream in oop?
1306
What is new keyword in oops?
1050
What is encapsulation and abstraction? How are they implemented in C++?
1140
Why is abstraction used?
1100
Why is abstraction needed?
1046
What are properties in oop?
1097