Skip to content

Commit 7770911

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 16cf462 commit 7770911

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

height_of_tree/tree.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Optional, List
22

3+
34
class Node:
45
def __init__(self, info: int) -> None:
56
self.info: int = info
@@ -13,6 +14,7 @@ def __str__(self) -> str:
1314
"""
1415
return str(self.info)
1516

17+
1618
class BinarySearchTree:
1719
def __init__(self) -> None:
1820
self.root: Optional[Node] = None
@@ -47,6 +49,7 @@ def create(self, val: int) -> None:
4749
else:
4850
break
4951

52+
5053
def height(node: Optional[Node]) -> int:
5154
"""
5255
>>> height(None)
@@ -64,6 +67,7 @@ def height(node: Optional[Node]) -> int:
6467
return -1
6568
return 1 + max(height(node.left), height(node.right))
6669

70+
6771
def tree_height_from_list(data: List[int]) -> int:
6872
"""
6973
>>> tree_height_from_list([3,2,5,6])
@@ -78,6 +82,8 @@ def tree_height_from_list(data: List[int]) -> int:
7882
bst.create(x)
7983
return height(bst.root)
8084

85+
8186
if __name__ == "__main__":
8287
import doctest
88+
8389
doctest.testmod()

0 commit comments

Comments
 (0)