(+84) 236.3827111 ex. 402

Hàm chèn một giá trị vào BST


struct Node
{ int Data;
Node * Left, * Right;
};
typedef Node * Tree;
void CREATE(Tree & T)
{
T=NULL;
}
void INSERT(Tree & T, int x)
{ Node * e=new Node;
e->Data=x;
e->Left=NULL;
e->Right=NULL;
if(T==NULL) T=e;
else
if(xData) INSERT(T->Left,x);
else
if(x>T->Data) INSERT(T->Right,x);
else cout<<"\n Gia tri "<
}