Fix broken balance
method
This commit is contained in:
parent
24225d7595
commit
479cac0393
|
@ -43,18 +43,18 @@ public class AVLSearchTree<T extends Comparable<T>> extends SortedBinaryTree<T>
|
|||
} else if (height(p.left) - height(p.right) == 2) {
|
||||
if (height(p.left.left) >= height(p.left.right)) {
|
||||
// TODO Implement (6.2)
|
||||
rotateR(p);
|
||||
p = rotateR(p);
|
||||
} else {
|
||||
// TODO Implement (6.2)
|
||||
rotateLR(p);
|
||||
p = 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);
|
||||
p = rotateL(p);
|
||||
} else {
|
||||
// TODO Implement (6.2)
|
||||
rotateRL(p);
|
||||
p = rotateRL(p);
|
||||
}
|
||||
}
|
||||
p.height = Math.max(height(p.left), height(p.right)) + 1;
|
||||
|
|
Loading…
Reference in a new issue