#include <stdio.h>
#include <alloc.h>
#include <stdlib.h>
#include <conio.h>
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.
No Answer is Posted For this Question
Be the First to Post Answer
write string class as your own class in java without using any built-in function
How long to learn object oriented programming?
What is overloading in oop?
I hv a same function name,arguments in both base class and dervied class, but the return type is different. Can we call this as a function overloading? Explain?
i got a backdoor offer in process global,Bangalore..Can i work with it?
c++ is a pure object oriented programming or not?
There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.
Describe these concepts: Polymorphism, Inheritance and Abstraction.
1. Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)
What is the difference between static polymorphism and dynamic polymorphism?
write a c++ code of diagonal matrix.
WAP to generate 2n+1 lines of the following pattern on the computer screen: