Aiml14 DS Exp10
Aiml14 DS Exp10
EXPERIMENT : 10
NAME : JAGE TANVI NARENDRA
ROLL NO. : AIML14
BATCH : A1
BRANCH : CSE(AIML)
AIM :
TO IMPLEMENTATION OF BINARY SEARCH TREE
SOURCE CODE :
#include<stdio.h>
#include<stdlib.h>
struct node
{
struct node *lchild;
int info;
struct node *rchild;
};
int main( )
{
struct node *root=NULL,*ptr;
int choice,k,p,i;
while(1)
{
printf("\n");
printf("1.Insert\n");
printf("2.Display\n");
printf("3.Quit\n");
printf("\nEnter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:
case 2:
printf("\n");
display(root,0,1);
printf("\n");
break;
case 3:
exit(1);
default:
printf("\nWrong choice\n");
}
}
return 0;
}
printf("%d", ptr->info);
display(ptr->lchild, level,0);
}
}/*End of display()*/
OUTPUT :
CONCLUSION :
From this experiment we have learnt the implementation of a binary search
tree.