Open canfeit opened 4 years ago
I think this line should be:
return this.rotationLR(node);
Why use left?
Hi,canfeit!
The author is correct,the function of rotationLR params is node.left
not node
, why ? maybe you should review rotationLR Function details.
first, use node.left
rotate to the left, node.left.right get balanced
second, use node
rotate to the right, node.left get balanced
rotationLR(node) {
node.left = this.rotationRR(node.left);
return this.rotationLL(node);
}
https://github.com/PacktPublishing/Learning-JavaScript-Data-Structures-and-Algorithms-Third-Edition/blob/2cedcaf8479a90400812bc85f1edd0e5db2debbf/LearningJavaScriptDataStructuresandAlgorithmsThirdEdition_Code/src/ts/data-structures/avl-tree.ts#L181 I think this line should be:
Why use left?