#include<iostream> #include<stdlib.h> typedef int EType; typedef struct tnode { EType data; struct tnode* left; struct tnode* right; }TNode; typedef struct tnode* BTREE; TNode* insertBST(BTREE T,EType x); TNode* insert_left(BTREE T,EType x); TNode* insert_right(BTREE T,EType x); TNode* find(BTREE T, EType x); int main(){ BTREE a,s;a=s=NULL; insertBST(a,4);insertBST(a,3); } TNode* insertBST(BTREE T,EType x){ TNode* comp; if(T==NULL){ comp=new TNode; if(comp==NULL)return comp; else{T->data=x; T->left=T->right=NULL; }T=comp; } else if(x<T->data)T->left=insertBST(T->left,x); else T->right=insertBST(T->right,x); return(T); } TNode* find(BTREE T, EType x){ if(T->data==x||T==NULL)return T; else if(x<T->data)return find(T->left,x); else return find(T->right,x); }
if (comp==NULL) return comp;
comp
InsertBST
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)