示例#1
0
def test_1():
    tree = create_binary_tree([0, -3, 5, -10, None, 9])
    assert (arr_to_tree([-10, -3, 0, 5, 9]) == tree)
示例#2
0
def test_2():
    tree = create_binary_tree([0, -10, 9, -20, -3, 5, 10])
    assert (arr_to_tree([-20, -10, -3, 0, 5, 9, 10]) == tree)
def test_1():
    tree = create_binary_tree([3, 9, 20, None, None, 15, 7])
    print(tree)
    assert (max_depth(tree) == 3)
def test_4():
    tree = create_binary_tree([10, 5, 15, None, None, 6, 20])
    assert (is_valid_search_tree(tree) == False)
def test_2():
    tree = create_binary_tree([1, 2, 2, None, 3, None, 3])
    assert (is_symmetric(tree) == False)
def test_1():
    tree = create_binary_tree([1, 2, 2, 3, 4, 4, 3])
    assert (is_symmetric(tree) == True)
def test_2():
    tree = create_binary_tree([1, 2, 2, None, 3, None, 3])
    assert (level_order(tree) == [[1], [2, 2], [3, 3]])
def test_1():
    tree = create_binary_tree([3, 9, 20, None, None, 15, 7])
    assert (level_order(tree) == [[3], [9, 20], [15, 7]])
示例#9
0
def test_2():
    tree = create_binary_tree([1, 2, 3])
    result = serialize(tree)
    assert (deserialize(result) == tree)