Exemple #1
0
 def test_mirror(self):
     tree = mirror(binary_search_tree())
     self.assertIsNotNone(tree)
     self.assertTrue(equals(tree, binary_search_tree_mirrored()))
Exemple #2
0
 def test_equals(self):
     self.assertTrue(equals(binary_search_tree(), binary_search_tree()))
     self.assertFalse(
         equals(binary_search_tree(), invalid_binary_search_tree()))
Exemple #3
0
 def test_sortedArrayToBST(self):
     tree = sortedArrayToBST([25, 50, 75, 100, 125, 150, 175])
     self.assertTrue(equals(tree, binary_search_tree()))
Exemple #4
0
 def test_clone(self):
     tree = binary_search_tree()
     othr = clone(tree)
     self.assertTrue(equals(tree, othr))
     self.assertFalse(id(tree) == id(othr))
Exemple #5
0
 def test_deleteInPlace(self):
     tree = deleteInPlace(binary_search_tree(), 50)
     self.assertFalse(contains(tree, 50))
     tree = deleteInPlace(binary_search_tree(), 51)
     self.assertTrue(equals(tree, binary_search_tree()))
Exemple #6
0
 def test_insertAndCopy(self):
     tree = binary_search_tree()
     othr = insertAndCopy(tree, 45)
     self.assertFalse(equals(tree, othr))
     self.assertTrue(contains(othr, 45))