From 2148500a39ea3394edc5738c16009bca00bec4d0 Mon Sep 17 00:00:00 2001 From: JUYOUNG Date: Mon, 4 Mar 2019 22:44:51 +0900 Subject: [PATCH] editing __remove() debugged the function '__remove()'. when remove rightmost node at the bottom, it didn't work. so I edited the function to work. --- data_structure/BinaryTree.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data_structure/BinaryTree.py b/data_structure/BinaryTree.py index 1c70276..b486639 100644 --- a/data_structure/BinaryTree.py +++ b/data_structure/BinaryTree.py @@ -121,7 +121,11 @@ def __remove(self, parent, cur, item): else: cur.val = self.__most_left_val_from_right_node(cur.right).val self.__removeitem(cur, cur.right, cur.val) - + else: + if cur.val > item: + self.__remove(cur, cur.left, item) + else: + self.__remove(cur, cur.right, item) def __most_left_val_from_right_node(self, cur): if cur.left is None: