def test_contains(): hashtable = Hashtable() hashtable.add("Hello", "It is me") actual = hashtable.contains('Hello') expected = True assert actual == expected actual2 = hashtable.contains("Where") expected2 = False assert actual2 == expected2
def tree_intersection(binary1, binary2): arr = [] tree1 = binary1.pre_order() tree2 = binary2.pre_order() hash = Hashtable() for root in tree1: hash.add(str(root), str(root)) for root in tree2: if hash.contains(str(root)): arr.append(root) if len(arr) == 0: return 'There are no intersections' else: return arr