diff --git a/pydatastructs/trees/binary_trees.py b/pydatastructs/trees/binary_trees.py index 33f368534..ed2d055fe 100644 --- a/pydatastructs/trees/binary_trees.py +++ b/pydatastructs/trees/binary_trees.py @@ -218,7 +218,7 @@ def insert(self, key, data=None): self.tree[walk].key = key self.tree[walk].data = data return None - new_node, prev_node, flag = TreeNode(key, data), 0, True + new_node, prev_node, flag = TreeNode(key, data), self.root_idx, True while flag: if not self.comparator(key, self.tree[walk].key): if self.tree[walk].right is None: