From abdc673fa8a4e49fad8da88ef35d5cdadd0719f7 Mon Sep 17 00:00:00 2001 From: CaedenPH Date: Fri, 14 Oct 2022 23:09:55 +0100 Subject: [PATCH 1/2] refactor: Make code more understandable --- .../binary_tree/binary_tree_traversals.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/data_structures/binary_tree/binary_tree_traversals.py b/data_structures/binary_tree/binary_tree_traversals.py index 378598bb096d..16001c9a8063 100644 --- a/data_structures/binary_tree/binary_tree_traversals.py +++ b/data_structures/binary_tree/binary_tree_traversals.py @@ -15,7 +15,20 @@ class Node: def make_tree() -> Node | None: - return Node(1, Node(2, Node(4), Node(5)), Node(3)) + r""" + The below tree + 1 + / \ + 2 3 + / \ + 4 5 + """ + tree = Node(1) + tree.left = Node(2) + tree.right = Node(3) + tree.left.left = Node(4) + tree.left.right = Node(5) + return tree def preorder(root: Node | None) -> list[int]: From ced58c8c07113e992c768667a10356093d3c4c3a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:16:16 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- data_structures/binary_tree/binary_tree_traversals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/binary_tree/binary_tree_traversals.py b/data_structures/binary_tree/binary_tree_traversals.py index 16001c9a8063..54b1dc536f32 100644 --- a/data_structures/binary_tree/binary_tree_traversals.py +++ b/data_structures/binary_tree/binary_tree_traversals.py @@ -19,7 +19,7 @@ def make_tree() -> Node | None: The below tree 1 / \ - 2 3 + 2 3 / \ 4 5 """