mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 17:38:02 +00:00
Update bst insert to return the inserted node (#81)
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user