Skip to content

Commit d12637c

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

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

height_of_tree/tree.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class Node:
22
def __init__(self, info: int) -> None:
33
self.info = info
4-
self.left: 'Node|None' = None
5-
self.right: 'Node|None' = None
4+
self.left: "Node|None" = None
5+
self.right: "Node|None" = None
66

77
def __str__(self) -> str:
88
"""
@@ -11,9 +11,10 @@ def __str__(self) -> str:
1111
"""
1212
return str(self.info)
1313

14+
1415
class BinarySearchTree:
1516
def __init__(self) -> None:
16-
self.root: 'Node|None' = None
17+
self.root: "Node|None" = None
1718

1819
def create(self, val: int) -> None:
1920
"""
@@ -45,7 +46,8 @@ def create(self, val: int) -> None:
4546
else:
4647
break
4748

48-
def height(node: 'Node|None') -> int:
49+
50+
def height(node: "Node|None") -> int:
4951
"""
5052
>>> height(None)
5153
-1
@@ -62,6 +64,7 @@ def height(node: 'Node|None') -> int:
6264
return -1
6365
return 1 + max(height(node.left), height(node.right))
6466

67+
6568
def tree_height_from_list(data: list[int]) -> int:
6669
"""
6770
>>> tree_height_from_list([3,2,5,6])
@@ -74,6 +77,8 @@ def tree_height_from_list(data: list[int]) -> int:
7477
bst.create(x)
7578
return height(bst.root)
7679

80+
7781
if __name__ == "__main__":
7882
import doctest
83+
7984
doctest.testmod()

0 commit comments

Comments
 (0)