shared_ptr<Node> rightSonPtr = unbalancedVertex->rightSon;
shared_ptr<Node> rightSonLeftSon = rightSonPtr->leftSon;
// Move the left child of rightSon (if it exists) to become the new right child of unbalancedVertex
unbalancedVertex->rightSon = rightSonLeftSon;
if (rightSonLeftSon != nullptr) {
rightSonLeftSon->father = unbalancedVertex;
}
// Update the parent and child pointers for the rotation
rightSonPtr->leftSon = unbalancedVertex;
rightSonPtr->father =unbalancedVertex->father;```
i dont understand why after the last line , the
unbalancedVertex->rightSon
is the original unbalancedVertex intself.
any idea what i mess with the pointers?
#Avl tree help
3 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
have you stepped through it in a debugger?