### binary search tree problem

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677`` `````` #include using namespace std; typedef struct node{ node*right; node*left; node*father; int height; int key; }node,*pnode; void insert(pnode p1,int n) { int h=1; //init pnode p; p=new node; p->key=n; p->father=NULL; p->right=NULL; p->left=NULL; if(p1==NULL) {p1=p; return ; }//logic if(p1->left==NULL&&nkey) { p1->left=p; p->father=p1; return ; } if(p1->right==NULL&&n>p1->key) { p1->right=p; p->father=p1; return ; } if(nkey)//recursive {insert(p1->left,n);} else if(n>p1->key)//recursive {insert(p1->right,n);} else h++; p->height=h; return ; } pnode find(node*p,int k) { if(!p) return NULL; if(kkey) return find(p->left,k); else if(k>p->key) return find(p->right,k); else return p; } int main() { pnode p=NULL; insert(p,1); insert(p,4); insert(p,3); pnode p2=find(p,4); cout<key; system("pause"); return 0; }``````

It exit with warning
Last edited on
I change line 17`p=new node; ` to p=(pnode)malloc(sizeof(node)); but it still doesn't work .
What I mean is that line 23 `p1=p;` is useless.