I want to copy a part of a tree.
I hope someone can give some tips.
Thanks!
struct node { ... int num_number; //number of children nodes node **children; //pointer point to children nodes. When I copy the node, how can I deal with **children? Right now, there is no children yet. } void copy_tree(node *node, node *T) { int i; char number[12] = {0}; //used in case of if int n = node->num_children; if (node == NULL) T = NULL; if(...) { .... // copy the node } else { .... // copy the node } for(i=0; i<n; i++) copy_tree(node->children[i], T->children[i]); // I want to copy the children nodes recursively, but the new node has no children; that is T->children not existing, how can I copy the children nodes and allocate to parent?
I hope someone can give some tips.
Thanks!