Saturday, September 12, 2009

Create a copy of a tree

Node *copy(mynode *root)
{
Node *temp;

if(root==NULL)return(NULL);

temp = (mynode *) malloc(sizeof(mynode));
temp->value = root->value;

temp->left = copy(root->left);
temp->right = copy(root->right);

return(temp);
}

No comments:

Post a Comment