Code:
typedef struct node node;
struct node{
int value,count;
node *lc,*rc;
};
node * CopyOf (node* T)
{
if (T ==NULL)
return NULL;
node* temp;
temp = (node *)malloc(sizeof(node));
temp-> value = T->value;
temp->lc = CopyOf(T->lc);
temp->rc = CopyOf(T->rc);
return temp;
}
node * Merge(node* T1 , node* T2)
{
node* result, *temp, *aux;
if ((!T1)&&(!T2))
return NULL;
if (!T1)
return T2;
if (!T2)
return T1;
temp =(node *)malloc(sizeof(node));
temp-> value = T1->value;
temp->lc = temp->rc = NULL;
aux = Merge(T2, T1->lc);
result = Merge(aux, T1->rc);
BST_insert( temp, &result);
return result;
}
the main function is merge
it takes two bst trees and merge them into one big copy new bst tree.
insert is a helping function which adds a new node to the tree
i cant understand the merging last past
how they use aux
whats the schematics of this?