예제 #1
0
    def test_balanced_tree(self):
        root = Tree(1)
        root.set_left(4)
        root.set_right(5)
        root.left.set_left(3)
        root.left.set_right(5)
        root.right.set_left(7)
        root.right.set_right(9)
        answer = [['|', '|', '|', '1', '|', '|', '|']]
        answer.append(['|', '4', '|', '|', '|', '5', '|'])
        answer.append(['3', '|', '5', '|', '7', '|', '9'])

        assert root.print_tree() == answer
예제 #2
0
 def test_get_height_3(self):
     root = Tree(2)
     root.set_right(3)
     assert root.get_height() == 2