Simpilfied bst challenge.

This commit is contained in:
Donne Martin
2015-08-01 17:44:14 -04:00
parent e55c7ee1c6
commit 31058abf3a
5 changed files with 106 additions and 63 deletions

18
graphs_trees/bst/bst.py Normal file
View File

@@ -0,0 +1,18 @@
class Node(object):
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def insert(root, data):
if data <= root.data:
if root.left is None:
root.left = Node(data)
else:
insert(root.left, data)
else:
if root.right is None:
root.right = Node(data)
else:
insert(root.right, data)