solved Task 3
This commit is contained in:
parent
2c27dd7629
commit
a63689aeb0
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue