diff --git a/build/CMakeFiles/RBlib.dir/src/Red-Black.cpp.o b/build/CMakeFiles/RBlib.dir/src/Red-Black.cpp.o index 7927342..282fd2e 100644 Binary files a/build/CMakeFiles/RBlib.dir/src/Red-Black.cpp.o and b/build/CMakeFiles/RBlib.dir/src/Red-Black.cpp.o differ diff --git a/build/libRBlib.a b/build/libRBlib.a index bd19625..27143a9 100644 Binary files a/build/libRBlib.a and b/build/libRBlib.a differ diff --git a/build/main b/build/main index b1e6290..4d9d446 100755 Binary files a/build/main and b/build/main differ diff --git a/src/Red-Black.cpp b/src/Red-Black.cpp index f521a67..cc12cb5 100644 --- a/src/Red-Black.cpp +++ b/src/Red-Black.cpp @@ -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){