Fix avl_tree_height.
authorcoderain <coderain@sdf.org>
Tue, 17 Jan 2017 16:32:18 +0000 (17:32 +0100)
committercoderain <coderain@sdf.org>
Tue, 17 Jan 2017 16:32:18 +0000 (17:32 +0100)
kernel/src/avl_tree.c

index 8771fc1153b322341523554b3b76030c897be80e..3061edfc0e96dd93f61a6884de26e7344e9f2ab3 100644 (file)
@@ -23,7 +23,7 @@
 static int avl_tree_height(avl_tree_t *tree)
 {
     if (tree == NULL) return 0;
-    return 1 + avl_tree_height(tree->left) + avl_tree_height(tree->right);
+    return 1 + MAX(avl_tree_height(tree->left), avl_tree_height(tree->right));
 }
 
 static int avl_tree_balance_factor(avl_tree_t *tree)