binary search tree
I wrote the following code to find duplicate elements in an array. But this doesnt run. There is no compilation error , though!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct NODE
{
int info;
NODE* father;
NODE* left;
NODE* right;
};
NODE* createnode(int x)
{
NODE* temp;
temp=(NODE*)malloc(sizeof(NODE));
temp->father=NULL;
temp->left=NULL;
temp->right=NULL;
temp->info=x;
return temp;
}
void insertnode(NODE **start,int x)
{
int count;
NODE* temp,*temp1,*temp2;
temp1==*start;
temp=createnode(x);
if(*start==NULL)
{*start=temp;printf("a");}
else
{
count=0;
while(temp1!=NULL)
{
if(temp->info>temp1->info)
{temp2=temp1;temp1=temp1->right;printf("b");}
else if(temp->info<temp1->info)
{temp2=temp1;temp1=temp1->left;printf("c");}
else if(temp->info==temp1->info)
{printf("%d %d duplicacy detected\n",temp1->info,temp->info);count=1;printf("d");break;}
}
if(count==0)
{
temp->father=temp2;
temp1=temp;printf("e");
}
}
}
int main()
{
int n,i,arr[15];
NODE *start=NULL;
printf("enter the size of array");
scanf("%d",&n);
printf("enter %d numbers",n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
for(i=0;i<n;i++)
insertnode(&start,arr[i]);
getch();
}
|
what is the compilation error?
problem is solved. the error is in line 28. :)
Topic archived. No new replies allowed.