#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.
3700
What are the two different types of polymorphism?
1086
What is destructor in oop?
986
Can a varargs method be overloaded?
1038
How do you define a class in oop?
1059
What is oops with example?
996
What is abstract class in oops?
973
what are the ways in which a constructors can be called?
2045
What does and I oop and sksksk mean?
1108
What is abstraction with example?
1040
What causes polymorphism?
1067
What is the purpose of enum?
964
Following are the class specifications:
class {int a};
class {int b};
Using friend funtion,calculate the max of two objects and
display it.
2408
What is object in oop?
1060
What is the use of oops?
993