Update bst insert to return the inserted node (#81)

This commit is contained in:
Donne Martin
2016-06-25 21:03:26 -04:00
committed by GitHub
parent 7882ed9ae7
commit 042161dc3b
4 changed files with 29 additions and 25 deletions

View File

@@ -19,11 +19,13 @@ def insert(root, data):
if root.left is None:
root.left = insert(root.left, data)
root.left.parent = root
return root.left
else:
insert(root.left, data)
return insert(root.left, data)
else:
if root.right is None:
root.right = insert(root.right, data)
root.right.parent = root
return root.right
else:
insert(root.right, data)
return insert(root.right, data)