Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void copyLocalTreeRecursive(Node *x, RBTree *tree) {
- if (x->right != NIL)
- copyLocalTreeRecursive(x->right, tree);
- if (x->left != NIL)
- copyLocalTreeRecursive(x->left, tree);
- //If we find the key, we add the num_vegades of the local tree to the global tree,
- // if not, we create a new node in the global tree with the info of the local one
- RBData *nodeFound = findNode(tree, x->data->key);
- if (nodeFound) {
- nodeFound->num_vegades += x->data->num_vegades;
- } else {
- RBData *newNode = malloc(sizeof(RBData));
- newNode->key = malloc(sizeof(char *) * strlen(x->data->key));
- strcpy(newNode->key,x->data->key);
- newNode->num_vegades = x->data->num_vegades;
- insertNode(tree, newNode);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement