diff options
Diffstat (limited to 'avl.c')
| -rw-r--r-- | avl.c | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -34,7 +34,7 @@ insert_r(T x, struct tree_node *p, bool *h) | |||
| 34 | *h = true; | 34 | *h = true; |
| 35 | 35 | ||
| 36 | p = malloc(sizeof *p); | 36 | p = malloc(sizeof *p); |
| 37 | if ( p != NULL ) { | 37 | if ( p ) { |
| 38 | p->left = NULL; | 38 | p->left = NULL; |
| 39 | p->right = NULL; | 39 | p->right = NULL; |
| 40 | p->bal = 0; | 40 | p->bal = 0; |
| @@ -215,7 +215,7 @@ balanceR(struct tree_node *p, bool *h) | |||
| 215 | static void | 215 | static void |
| 216 | del(struct tree_node **q, struct tree_node **r, bool *h) | 216 | del(struct tree_node **q, struct tree_node **r, bool *h) |
| 217 | { | 217 | { |
| 218 | if ( (*r)->right != NULL ) { | 218 | if ( (*r)->right ) { |
| 219 | del(q, &(*r)->right, h); | 219 | del(q, &(*r)->right, h); |
| 220 | if ( *h ) | 220 | if ( *h ) |
| 221 | *r = balanceR(*r, h); | 221 | *r = balanceR(*r, h); |
