From fb232f75e9f6ad87b6084dbbea5e8a0949f0a59e Mon Sep 17 00:00:00 2001 From: ayush Date: Tue, 25 Oct 2016 19:06:13 +0530 Subject: [PATCH] fixed bug in binarysearchtree.py --- trees/binarysearchtree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trees/binarysearchtree.py b/trees/binarysearchtree.py index 14885c0..fb573e3 100644 --- a/trees/binarysearchtree.py +++ b/trees/binarysearchtree.py @@ -100,13 +100,13 @@ def insert(self, value): else: node = self.root while node and node.value != value: + if node.value == value: + return parent = node if node.value < value: node = node.right else: node = node.left - if node.value == value: - return if parent.value > value: parent.left = new_node else: