From d6e1a5309d16524f7dfcba0dcd6ea6fe77b3f09d Mon Sep 17 00:00:00 2001 From: Mineplay Date: Sun, 31 Aug 2025 13:41:51 -0500 Subject: [PATCH] fix(search tree): fixed removal of nodes with only right sided nodes --- Include/Fledasty/Trees/BinarySearchTree.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Include/Fledasty/Trees/BinarySearchTree.h b/Include/Fledasty/Trees/BinarySearchTree.h index 6feb826..c7520de 100644 --- a/Include/Fledasty/Trees/BinarySearchTree.h +++ b/Include/Fledasty/Trees/BinarySearchTree.h @@ -184,9 +184,7 @@ FledastyError fledasty_binary_search_tree_##name##_remove(FledastyBinarySearchTr while (replacement_node->right != NULL) { \ replacement_node = replacement_node->right; \ } \ - } \ \ - if (replacement_node != NULL) { \ replacement_node->left = current_node->left; \ if (current_node->left != NULL) { \ current_node->left->parent = replacement_node; \ @@ -196,7 +194,9 @@ FledastyError fledasty_binary_search_tree_##name##_remove(FledastyBinarySearchTr if (current_node->right != NULL) { \ current_node->right->parent = replacement_node; \ } \ + } \ \ + if (replacement_node != NULL) { \ if (replacement_node->parent->right == replacement_node) { \ replacement_node->parent->right = NULL; \ } else { \