J'ai de la difficulté à comprendre pourquoi le code de rotation de l'arborescence ci-dessous fonctionne. Si T2
points à y.left
et y.left
points à , est-ce que cela fait la dernière affectation x.right = T2
égale à x.right = x
? Le pointeur ne doit-il pas pointer vers la position initiale T2
?Pointeurs dans la rotation d'arbre AVL
Node leftRotate(Node x) {
Node y = x.right;
Node T2 = y.left;
// Perform rotation
y.left = x;
x.right = T2;
// Update heights
x.height = max(height(x.left), height(x.right)) + 1;
y.height = max(height(y.left), height(y.right)) + 1;
// Return new root
return y;
}