7
7
"""
8
8
9
9
10
- def binaryTreeMirrorDict (root : int , binary_tree : dict = {}, binary_tree_mirror : dict = {}):
10
+ def binaryTreeMirrorDict (
11
+ root : int , binary_tree : dict = {}, binary_tree_mirror : dict = {}
12
+ ):
11
13
if root is None or root not in binary_tree .keys ():
12
14
return
13
15
left_child = binary_tree [root ][0 ]
@@ -16,6 +18,7 @@ def binaryTreeMirrorDict(root: int, binary_tree: dict = {}, binary_tree_mirror:
16
18
binaryTreeMirrorDict (left_child , binary_tree , binary_tree_mirror )
17
19
binaryTreeMirrorDict (right_child , binary_tree , binary_tree_mirror )
18
20
21
+
19
22
def binaryTreeMirror (root : int , binary_tree : dict = {}) -> dict :
20
23
"""
21
24
>>> binaryTreeMirror(1, { 1: [2,3], 2: [4,5], 3: [6,7], 7: [8,9]})
@@ -32,7 +35,7 @@ def binaryTreeMirror(root: int, binary_tree: dict = {}) -> dict:
32
35
33
36
34
37
if __name__ == "__main__" :
35
- binary_tree = { 1 : [2 ,3 ], 2 : [4 ,5 ], 3 : [6 ,7 ], 4 : [10 ,11 ], 5 : [12 ,13 ],7 : [8 ,9 ]}
38
+ binary_tree = {1 : [2 , 3 ], 2 : [4 , 5 ], 3 : [6 , 7 ], 4 : [10 , 11 ], 5 : [12 , 13 ], 7 : [8 , 9 ]}
36
39
root = 1
37
40
print ("Binary tree:" , sep = " " )
38
41
print (binary_tree )
0 commit comments