diff options
| author | Thomas Schmucker <ts@its1.de> | 2020-08-12 17:40:21 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2020-08-12 17:40:21 +0200 |
| commit | 5f4ca38289d5117dba42f495518a04486fec799c (patch) | |
| tree | 939d4fb97eadeee95da405f3edb5fce90db9b44a /tree.c | |
| parent | dc71e5faf4752f5ceaedd5beae55cea40dbb007f (diff) | |
| download | data-structures-5f4ca38289d5117dba42f495518a04486fec799c.tar.gz data-structures-5f4ca38289d5117dba42f495518a04486fec799c.tar.bz2 data-structures-5f4ca38289d5117dba42f495518a04486fec799c.zip | |
Variable 'root' nach 'tree
Diffstat (limited to 'tree.c')
| -rw-r--r-- | tree.c | 10 |
1 files changed, 5 insertions, 5 deletions
| @@ -60,11 +60,11 @@ tree_insert(struct tree_node *tree, T key) | |||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | struct tree_node * | 62 | struct tree_node * |
| 63 | tree_insert_it(struct tree_node *root, T key) | 63 | tree_insert_it(struct tree_node *tree, T key) |
| 64 | { | 64 | { |
| 65 | struct tree_node *parent = NULL; | 65 | struct tree_node *parent = NULL; |
| 66 | 66 | ||
| 67 | for ( struct tree_node *curr = root; curr != NULL; ) { | 67 | for ( struct tree_node *curr = tree; curr != NULL; ) { |
| 68 | parent = curr; | 68 | parent = curr; |
| 69 | 69 | ||
| 70 | if ( key < curr->key ) { | 70 | if ( key < curr->key ) { |
| @@ -75,7 +75,7 @@ tree_insert_it(struct tree_node *root, T key) | |||
| 75 | } | 75 | } |
| 76 | else { /* key == current->key */ | 76 | else { /* key == current->key */ |
| 77 | curr->count++; | 77 | curr->count++; |
| 78 | return root; | 78 | return tree; |
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | 81 | ||
| @@ -89,7 +89,7 @@ tree_insert_it(struct tree_node *root, T key) | |||
| 89 | new_node->right = NULL; | 89 | new_node->right = NULL; |
| 90 | 90 | ||
| 91 | if ( parent == NULL ) { | 91 | if ( parent == NULL ) { |
| 92 | root = new_node; | 92 | tree = new_node; |
| 93 | } | 93 | } |
| 94 | else if ( key < parent->key ) { | 94 | else if ( key < parent->key ) { |
| 95 | parent->left = new_node; | 95 | parent->left = new_node; |
| @@ -102,7 +102,7 @@ tree_insert_it(struct tree_node *root, T key) | |||
| 102 | ERROR("out of memory"); | 102 | ERROR("out of memory"); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | return root; | 105 | return tree; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | static struct tree_node * | 108 | static struct tree_node * |
