// Left right case
if (this.getBalanceFactor(node.left) === BalanceFactor.SLIGHTLY_UNBALANCED_RIGHT) {
return this.rotationLR(node.left);
}
I think this code is not correct;
eg:
10
↙ ↘
6 。。。
↙ ↘
3 8
↘
4
remove node key = 8;
node key=6 is not balanced;
condition accord with balanceFactor === BalanceFactor.UNBALANCED_RIGHT;
run return this.rotationLR(node.left);, it's will be throw error;
in fact, this condition need return this.rotationLR(node);
also, Right-left-case has same error
// Right left case
if (this.getBalanceFactor(node.right) === BalanceFactor.SLIGHTLY_UNBALANCED_LEFT) {
// need change code
return this.rotationRL(node.right);
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
return this.rotationRL(node);
}
Fixes #14 AVL-tree removeNode function
I think this code is not correct; eg:
key = 8
;key=6
is not balanced;balanceFactor === BalanceFactor.UNBALANCED_RIGHT
;return this.rotationLR(node.left);
, it's will be throw error;in fact, this condition need
return this.rotationLR(node)
;also, Right-left-case has same error