Trying to understand binary tree from array
This commit is contained in:
+38
-3
@@ -144,7 +144,9 @@ def test_min_stack(ops: list[tuple[str] | tuple[str, int]], expected: list[int |
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_sort_linked_list(head: stdlib.ListNode | None, expected: stdlib.ListNode | None):
|
||||
def test_sort_linked_list(
|
||||
head: stdlib.LinkedListNode | None, expected: stdlib.LinkedListNode | None
|
||||
):
|
||||
if head is None:
|
||||
assert stuff.sort_linked_list(head) == expected
|
||||
return
|
||||
@@ -168,7 +170,7 @@ def test_sort_linked_list(head: stdlib.ListNode | None, expected: stdlib.ListNod
|
||||
],
|
||||
)
|
||||
def test_connect_binary_tree_right(
|
||||
root: stdlib.Node | None, expected: list[int | None] | None
|
||||
root: stdlib.ConnectableBinaryTreeNode | None, expected: list[int | None] | None
|
||||
):
|
||||
if expected is None:
|
||||
assert root is None
|
||||
@@ -192,5 +194,38 @@ def test_connect_binary_tree_right(
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_connect_binary_tree_sum_numbers(root: stdlib.Node | None, expected: int):
|
||||
def test_connect_binary_tree_sum_numbers(
|
||||
root: stdlib.BinaryTreeNode | None, expected: int
|
||||
):
|
||||
assert stuff.sum_binary_tree_path_ints(root) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("inlist", "expected"),
|
||||
[
|
||||
(
|
||||
[3, 5, 1, 6, 2, 0, 8, None, None, 7, 4],
|
||||
stdlib.TreeNode(
|
||||
3,
|
||||
left=stdlib.TreeNode(
|
||||
5,
|
||||
left=stdlib.TreeNode(6),
|
||||
right=stdlib.TreeNode(
|
||||
2,
|
||||
left=stdlib.TreeNode(7),
|
||||
right=stdlib.TreeNode(4),
|
||||
),
|
||||
),
|
||||
right=stdlib.TreeNode(
|
||||
1,
|
||||
left=stdlib.TreeNode(0),
|
||||
right=stdlib.TreeNode(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_binary_tree_from_list(
|
||||
inlist: list[int | None], expected: stdlib.BinaryTreeNode | None
|
||||
):
|
||||
assert stuff.binary_tree_from_list(inlist) == expected
|
||||
|
||||
Reference in New Issue
Block a user