def test3(self): bst = BinarySearchTree(5) ints = [] for val in ints: bst.insertion(val) self.assertEqual(post_order_dfs_iterative(bst.root), [5])
def test4(self): bst = BinarySearchTree(5) ints = [] for val in ints: bst.insertion(val) self.assertEqual(post_order_dfs_recursive(bst.root, []), [5])
def test1(self): bst = BinarySearchTree(5) ints = [3, 5, 1, 2, -5, -9] for val in ints: bst.insertion(val) self.assertEqual(breadth_first_search(bst.root), [[5], [3, 5], [1], [-5, 2], [-9]])
def test2(self): bst = BinarySearchTree(5) ints = [3, 5, 1, 2, -5, -9] for val in ints: bst.insertion(val) self.assertEqual(post_order_dfs_recursive(bst.root, []), [-9, -5, 2, 1, 3, 5, 5])
def testLookup(self): bst = BinarySearchTree(4) ints = [1, 2, 3, 5, 6, 7, 8] for val in ints: bst.insertion(val) for val in ints: self.assertEqual(bst.lookup(val).val, val)
def testDelete(self): bst = BinarySearchTree(4) ints = [1, 2, 3, 5, 6, 7, 8] for val in ints: bst.insertion(val) bst.delete(5) bst.delete(4) self.assertEqual(None, bst.lookup(5)) self.assertEqual(None, bst.lookup(4)) self.assertEqual(validateBST(bst), True)
def testInsertion(self): bst = BinarySearchTree(3) for val in range(8): bst.insertion(val) self.assertEqual(validateBST(bst), True)