Skip to content

Commit 871788c

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

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

data_structures/binary_tree/binary_tree_mirror.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ def mirror_subtree(tree: dict, root: int):
88
if right:
99
mirror_subtree(tree, right)
1010

11+
1112
def mirror_binary_tree(tree: dict, root: int = 1) -> dict:
1213
"""
1314
Returns the mirror of the given binary tree starting from the root.
14-
15+
1516
>>> mirror_binary_tree({1: [2, 3], 2: [4, 5], 3: [6, 7], 7: [8, 9]}, 1)
1617
{1: [3, 2], 2: [5, 4], 3: [7, 6], 7: [9, 8]}
1718
>>> mirror_binary_tree({1: [2, 3], 2: [4, 5], 3: [6, 7], 4: [10, 11]}, 1)
@@ -34,8 +35,10 @@ def mirror_binary_tree(tree: dict, root: int = 1) -> dict:
3435
mirror_subtree(mirrored_tree, root)
3536
return mirrored_tree
3637

38+
3739
if __name__ == "__main__":
3840
import doctest
41+
3942
doctest.testmod()
4043

4144
binary_tree = {1: [2, 3], 2: [4, 5], 3: [6, 7], 7: [8, 9]}

0 commit comments

Comments
 (0)