aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tuckerevans24@gmail.com>2020-07-24 15:25:59 -0400
committerTucker Evans <tuckerevans24@gmail.com>2020-07-24 15:25:59 -0400
commit1cd08117d9506d72bf4bf87a12ad4720d0892407 (patch)
treecd8569d1480f1df94309b5345472386d1bbd1b7c
parentcb80c9dcad5f5def30d62995e38ee8894d8909de (diff)
Fix map AVL rotations
-rw-r--r--collections/map/map.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/collections/map/map.c b/collections/map/map.c
index 015a3cb..5ad0b65 100644
--- a/collections/map/map.c
+++ b/collections/map/map.c
@@ -117,18 +117,18 @@ struct map_node **root;
return;
if (map_height((*root)->left) > map_height((*root)->right)) {
- if(map_bal_factor((*root)->left) >= 0) {
+ if(map_bal_factor((*root)->left) <= 0) {
map_rotate_right(root);
} else {
- map_rotate_right(&(*root)->left);
- map_rotate_left(root);
+ map_rotate_left(&(*root)->left);
+ map_rotate_right(root);
}
} else {
if (map_bal_factor((*root)->right) >= 0) {
map_rotate_left(root);
} else {
- map_rotate_left(&(*root)->right);
- map_rotate_right(root);
+ map_rotate_right(&(*root)->right);
+ map_rotate_left(root);
}
}