solved Task 3

This commit is contained in:
schrom01 2022-10-25 15:48:02 +02:00
parent 2c27dd7629
commit a63689aeb0
1 changed files with 5 additions and 1 deletions

View File

@ -8,7 +8,11 @@ package ch.zhaw.ads;
*/
public class AVLSearchTree<T extends Comparable<T>> extends SortedBinaryTree<T> {
private boolean balanced(TreeNode<T> 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;
}