baum
diff baum.c @ 46:22305a6e128d
added deep copy and fixed so node times
author | meillo@marmaro.de |
---|---|
date | Sun, 02 Mar 2008 10:29:55 +0100 |
parents | 0b82169d4129 |
children | c31b5bb6d493 |
line diff
1.1 --- a/baum.c Sat Mar 01 21:49:41 2008 +0100 1.2 +++ b/baum.c Sun Mar 02 10:29:55 2008 +0100 1.3 @@ -67,6 +67,17 @@ 1.4 return insert; 1.5 } 1.6 1.7 +struct Node* copyTree(struct Node* node) { 1.8 + if (node == NULL) { 1.9 + return NULL; 1.10 + } 1.11 + struct Node* tmp; 1.12 + tmp = newNode(node->name, node->value); 1.13 + tmp->down = copyTree(node->down); 1.14 + tmp->right = copyTree(node->right); 1.15 + return tmp; 1.16 +} 1.17 + 1.18 1.19 /* delete */ 1.20 void delete(struct Node* node) {