From d04f74f992ae8d100966ba33a5093109900f5ee1 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Mon, 31 Oct 2022 20:12:42 +0100 Subject: [PATCH] Implement `AVLSearchTree` --- app/src/main/java/ch/nuth/zhaw/exbox/AVLSearchTree.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ch/nuth/zhaw/exbox/AVLSearchTree.java b/app/src/main/java/ch/nuth/zhaw/exbox/AVLSearchTree.java index e226342..768e99f 100644 --- a/app/src/main/java/ch/nuth/zhaw/exbox/AVLSearchTree.java +++ b/app/src/main/java/ch/nuth/zhaw/exbox/AVLSearchTree.java @@ -19,7 +19,7 @@ public class AVLSearchTree> extends SortedBinaryTree @Override protected int calcSize(TreeNode p) { // TODO Implement (6.2) - throw new RuntimeException(); + return super.calcSize(p); } /** @@ -43,14 +43,18 @@ public class AVLSearchTree> extends SortedBinaryTree } else if (height(p.left) - height(p.right) == 2) { if (height(p.left.left) >= height(p.left.right)) { // TODO Implement (6.2) + rotateR(p); } else { // TODO Implement (6.2) + rotateLR(p); } } else if (height(p.right) - height(p.left) == 2) { if (height(p.right.right) >= height(p.right.left)) { // TODO Implement (6.2) + rotateL(p); } else { // TODO Implement (6.2) + rotateRL(p); } } p.height = Math.max(height(p.left), height(p.right)) + 1;