Ejemplo n.º 1
0
 def test_insert_with_7_items(self):
     # Create a complete binary search tree of 7 items in level-order
     items = [4, 2, 6, 1, 3, 5, 7]
     tree = BinarySearchTree()
     for item in items:
         tree.insert(item)
     assert tree.root.data == 4
Ejemplo n.º 2
0
 def test_size(self):
     tree = BinarySearchTree()
     assert tree.size == 0
     tree.insert('B')
     assert tree.size == 1
     tree.insert('A')
     assert tree.size == 2
     tree.insert('C')
     assert tree.size == 3
Ejemplo n.º 3
0
    def test_insert_with_3_items(self):
        # Create a complete binary search tree of 3 items in level-order
        tree = BinarySearchTree()
        tree.insert(2)
        assert tree.root.data == 2
        tree.insert(1)
        assert tree.root.data == 2

        tree.insert(3)
        assert tree.root.data == 2