commit 692cb72f815fd0123a0deee96a3a09871da72719 parent a9f988c43e385d132c2d2e320b25fd0b2ed93f60 Author: Plat <plat@stellar-nexus.ru> Date: Thu, 23 Oct 2025 20:32:03 +0000 Fixed a few errors in rotations and balance2 Diffstat:
| M | final_solution.cpp | | | 6 | +++--- |
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/final_solution.cpp b/final_solution.cpp @@ -154,7 +154,7 @@ get_balance_factor(Node* root) Node* right_turn(Node* root) { - if (!root || !root->right) + if (!root || !root->left) return root; Node* buf = root->left; @@ -167,7 +167,7 @@ right_turn(Node* root) Node* left_turn(Node* root) { - if (!root || !root->left) + if (!root || !root->right) return root; Node* buf = root->right; @@ -207,7 +207,7 @@ balance2(Node* root) } if (bf < -1) { - if (get_balance_factor(root->left) > 0) + if (get_balance_factor(root->right) > 0) root->right = right_turn(root->right); return left_turn(root); }