Exemplo n.º 1
0
def test():
    from leet_code_pkg import BinaryTree
    t_c = BinaryTree()
    #t_c.binarytreemake()
    #t_c.print_tree_BFS_layer(t_c.tree)

    t= TreeNode
    bt = tr = t('a')
    tr.left, tr.right = t('b'), t('b')
    tr = bt.left
    tr.left, tr.right = t('c'), t('d')
    tr = bt.right
    tr.left, tr.right = t('d'), t('c')

    t_c.tree = bt
    t_c.print_tree_BFS_layer(t_c.tree)


    # 获取并执行Solution类中的解决方法
    so = Solution()
    func_list = [x for x in dir(so) if not x.startswith('__')]
    print('\r\n'*5, "方法列表:", func_list, '\r\n'*2)

    for _ in func_list:
        func = getattr(so, _)
        res = func(t_c.tree)
        print("方法:%s\r\n说明:%s"%( func.__name__, func.__doc__), '\r\n执行结果:')
        print(res)
        print('\r\n'*5)
Exemplo n.º 2
0
def test():
    from leet_code_pkg import BinaryTree
    t_c = BinaryTree()
    t_c.binarytreemake()
    t_c.print_tree_BFS_layer(t_c.tree)

    so = Solution()
    so._print_res(t_c.tree)
    pass
Exemplo n.º 3
0
def test():
    from leet_code_pkg import BinaryTree
    t_c = BinaryTree()
    t_c.binarytreemake()
    t_c.print_tree_BFS_layer(t_c.tree)

    so = Solution()
    res = so.is_same_tree_queue()
    pass
Exemplo n.º 4
0
def test():
    from leet_code_pkg import BinaryTree
    t_c = BinaryTree()
    t_c.binarytreemake()
    t_c.print_tree_BFS_layer()

    so = Solution()
    res = so.minDepth_DFS_recursion(t_c.tree)
    print(res)
    pass
Exemplo n.º 5
0
def test():
    from leet_code_pkg import BinaryTree
    t_c = BinaryTree()
    t_c.binarytreemake()
    t_c.print_tree_BFS_layer(t_c.tree)

    # 获取并执行Solution类中的解决方法
    so = Solution()
    func_list = [x for x in dir(so) if not x.startswith('__')]
    print('\r\n'*5, "方法列表:", func_list, '\r\n'*2)

    for _ in func_list:
        func = getattr(so, _)
        res = func(t_c.tree)
        print("方法:%s\r\n说明:%s"%( func.__name__, func.__doc__), '\r\n执行结果:')
        for element in res:
            print(element)
        print('\r\n'*5)