Skip to content

Commit 5c688df

Browse files
committed
fix typo
1 parent ed5b96b commit 5c688df

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

height_of_tree/tree.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self):
1313
self.root = None
1414

1515
def create(self, val):
16-
if self.root == None:
16+
if self.root is None:
1717
self.root = Node(val)
1818
else:
1919
current = self.root
@@ -39,6 +39,14 @@ def height(node):
3939
return 1 + max(height(node.left), height(node.right))
4040

4141
def tree_height_from_list(data):
42+
"""
43+
>>> tree_height_from_list([3,2,5,6])
44+
2
45+
>>> tree_height_from_list([1])
46+
0
47+
>>> tree_height_from_list([5,1,10,15,7])
48+
3
49+
"""
4250
bst = BinarySearchTree()
4351
for x in data:
4452
bst.create(x)

0 commit comments

Comments
 (0)