Exemplo n.º 1
0
    def test_binary_tree_3(self):

        a = node(1, None, None)
        b = node(7, a, None)
        c = node(5, b, None)
        d = node(3, c, None)

        t = Tree(d)

        assert np.mean(t.print_binary_tree() == np.array(
            [[
                '|', '|', '|', '|', '|', '|', '|', '3', '|', '|', '|', '|',
                '|', '|', '|'
            ],
             [
                 '|', '|', '|', '5', '|', '|', '|', '|', '|', '|', '|', '|',
                 '|', '|', '|'
             ],
             [
                 '|', '7', '|', '|', '|', '|', '|', '|', '|', '|', '|', '|',
                 '|', '|', '|'
             ],
             [
                 '1', '|', '|', '|', '|', '|', '|', '|', '|', '|', '|', '|',
                 '|', '|', '|'
             ]])) == 1.
Exemplo n.º 2
0
    def test_binary_tree_2(self):

        a = node(1, None, None)
        b = node(7, None, None)
        c = node(5, None, None)
        d = node(4, None, None)
        e = node(2, a, d)
        f = node(3, b, c)
        h = node(10, e, f)

        t = Tree(h)

        assert np.mean(t.print_binary_tree() == np.array(
            [['|', '|', '|', '10', '|', '|', '|'],
             ['|', '2', '|', '|', '|', '3', '|'],
             ['1', '|', '4', '|', '7', '|', '5']])) == 1.
Exemplo n.º 3
0
    def test_binary_tree_1(self):

        a = node(1, None, None)
        t = Tree(a)

        assert (t.print_binary_tree()) == ['1']