def test_inorder_traversal_stack(): tree = generate_binary_tree() assert inorder_traversal_stack(tree) == [4, 2, 5, 1, 3]
def test_postorder_traversal_recursive(): tree = generate_binary_tree() assert postorder_traversal_iterative(tree) == [4, 5, 2, 3, 1]
def test_preorder_traversal_recursive(): tree = generate_binary_tree() assert preorder_traversal_recursive(tree) == [1, 2, 4, 5, 3]
def test_preorder_traversal_morris(): tree = generate_binary_tree() assert preorder_traversal_morris(tree) == [1, 2, 4, 5, 3]
def test_level_order_traversal(): tree = generate_binary_tree() assert level_order_traversal(tree) == [[1], [2, 3], [4, 5]]