diff --git a/src/ch/zhaw/ads/AVLSearchTree.java b/src/ch/zhaw/ads/AVLSearchTree.java index 6a6441f..ad649f2 100644 --- a/src/ch/zhaw/ads/AVLSearchTree.java +++ b/src/ch/zhaw/ads/AVLSearchTree.java @@ -8,7 +8,11 @@ package ch.zhaw.ads; */ public class AVLSearchTree> extends SortedBinaryTree { private boolean balanced(TreeNode node) { - // TODO Implement (6.4) + if(Math.abs(calcHeight(node.right) - calcHeight(node.left)) > 1 + || (node.right != null && !balanced(node.right)) + || (node.left != null && !balanced(node.left))){ + return false; + } return true; }