Professional Documents
Culture Documents
ROLL NO - 40414004418
COURSE - MCA(1st Shift)
#include <stdio.h>
#include <stdlib.h>
struct btnode
{
int data;
struct btnode *l;
struct btnode *r;
}*root=NULL, *temp=NULL,*t1,*t2;
int flag = 1;
if (root==NULL)
root=temp;
else
search(root);
}
if (root == NULL)
{
printf("EMPTY");
return;
}
printf("Enter the Value to be deleted : ");
scanf("%d", &num);
t1 = root;
t2 = root;
search1(root, num);
}
void search1(struct btnode *t, int num)
{
if ((num>t->data))
{
t1 = t;
search1(t->r, num);
}
else if ((num < t->data))
{
t1 = t;
search1(t->l, num);
}
else if ((num==t->data))
{
delete1(t);
}
}
void delete1(struct btnode *t)
{
int k;
}
else
{
t1->r = t->l;
}
t = NULL;
free(t);
return;
}
while(1)
{
printf("\nEnter your choice : ");
scanf("%d", &ch);
switch (ch)
{
case 1:
insert();
break;
case 2:
inorder(root);
break;
case 3:
preorder(root);
break;
case 4:
postorder(root);
break;
case 5:
del();
break;
default :
printf("Wrong choice, Please enter correct choice ");
break;
}
}
}