AfanasevGad7

This is a task for our favourite professor
git clone git://git.stellar-nexus.ru/AfanasevGad7
Log | Files | Refs

commit 13eb3a9377c3daec4a441e257baaeaeceaee4d30
parent b30a68243c7ce23c036d329346b2fa17798a6941
Author: Plat <plat@stellar-nexus.ru>
Date:   Thu, 23 Oct 2025 19:37:32 +0000

An attempt to fix balance

Diffstat:
Mfinal_solution.cpp | 20++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/final_solution.cpp b/final_solution.cpp @@ -148,13 +148,9 @@ right_turn(Node* root) if (!root || !root->right) return root; - Node* buf = root->right; - - if (!buf || !root) return NULL; - - root->right = root->right->left; - buf->left = root; - + Node* buf = root->left; + root->left = buf->right; + buf->right = root; return buf; } @@ -165,13 +161,9 @@ left_turn(Node* root) if (!root || !root->left) return root; - Node* buf = root->left; - - if (!buf || !root) return NULL; - - root->left = root->left->right; - buf->right = root; - + Node* buf = root->right; + root->right = buf->left; + buf->left = root; return buf; }