Right rotate
This commit is contained in:
parent
218a07059f
commit
1eeb174511
Binary file not shown.
BIN
build/libRBlib.a
BIN
build/libRBlib.a
Binary file not shown.
BIN
build/main
BIN
build/main
Binary file not shown.
@ -145,7 +145,24 @@ void RB::display(Node *node, Trunk *prev, bool left){
|
||||
}
|
||||
|
||||
void RB::right_rot(Node* node){
|
||||
Node* y = node -> get_lchild();
|
||||
node -> set_lchild(y -> get_rchild());
|
||||
|
||||
if (y -> get_rchild() != nullptr)
|
||||
y -> get_rchild() -> set_parent(node);
|
||||
|
||||
y -> set_parent(node -> get_parent());
|
||||
if (node -> get_parent() == nullptr)
|
||||
this -> root = y;
|
||||
|
||||
else if (node -> get_parent() -> get_rchild() == node)
|
||||
node -> get_parent() -> set_rchild(y);
|
||||
|
||||
else
|
||||
node -> get_parent() -> set_lchild(y);
|
||||
|
||||
y -> set_rchild(node);
|
||||
node -> set_parent(y);
|
||||
}
|
||||
|
||||
void RB::left_rot(Node* node){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user