MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / make_tree

Function make_tree

data_structures/binary_tree/binary_tree_traversals.py:16–30  ·  view source on GitHub ↗

r""" The below tree 1 / \ 2 3 / \ 4 5

()

Source from the content-addressed store, hash-verified

14
15
16def make_tree() -> Node | None:
17 r"""
18 The below tree
19 1
20 / \
21 2 3
22 / \
23 4 5
24 """
25 tree = Node(1)
26 tree.left = Node(2)
27 tree.right = Node(3)
28 tree.left.left = Node(4)
29 tree.left.right = Node(5)
30 return tree
31
32
33def preorder(root: Node | None) -> Generator[int]:

Callers 1

mainFunction · 0.70

Calls 1

NodeClass · 0.70

Tested by

no test coverage detected