def tree_c(): test_tree = BinaryTree() test_tree.root = Node(-10) test_tree.root.left = Node(-13) test_tree.root.left.left = Node(-5) test_tree.root.left.left.left = Node(-20) test_tree.root.left.left.right = Node(-11) test_tree.root.left.right = Node(-6) test_tree.root.left.right.left = Node(-8) test_tree.root.right = Node(-30) test_tree.root.right.left = Node(-95) test_tree.root.right.right = Node(-1) return test_tree
def tree_a(): test_tree = BinaryTree() test_tree.root = Node(10) test_tree.root.left = Node(13) test_tree.root.left.left = Node(5) test_tree.root.left.left.left = Node(20) test_tree.root.left.left.right = Node(11) test_tree.root.left.right = Node(6) test_tree.root.left.right.left = Node(8) test_tree.root.right = Node(30) test_tree.root.right.left = Node(95) test_tree.root.right.right = Node(0) return test_tree
def tree_b(): test_tree = BinaryTree() test_tree.root = Node(8) test_tree.root.left = Node(13) test_tree.root.left.left = Node(12) test_tree.root.left.right = Node(30) test_tree.root.right = Node(5) test_tree.root.right.left = Node(50) test_tree.root.right.right = Node(7) test_tree.root.right.left.left = Node(11) return test_tree
def test_no_value(): tree1 = BinarySearchTree() tree1.root = Node(6) tree1.root.left = Node(5) tree1.root.right = Node(7) tree2 = BinarySearchTree() tree2.root = Node(9) tree2.root.right = Node(10) tree2.root.left = Node(8) actual = tree2.tree_intersection(tree1) expected = [] assert actual == expected
def test_one_match(): tree1 = BinarySearchTree() tree1.root = Node(6) tree1.root.left = Node(5) tree1.root.right = Node(7) tree2 = BinarySearchTree() tree2.root = Node(8) tree2.root.left = Node(6) tree2.root.right = Node(10) actual = tree2.tree_intersection(tree1) expected = [6] assert actual == expected
def tree_c(): test_tree = BinaryTree() test_tree.root = Node(15) test_tree.root.left = Node(10) test_tree.root.left.left = Node(7) test_tree.root.left.right = Node(16) test_tree.root.left.right.left = Node(12) test_tree.root.left.right.right = Node(17) test_tree.root.right = Node(25) test_tree.root.right.left = Node(20) test_tree.root.right.right = Node(35) test_tree.root.right.right.left = Node(30) test_tree.root.right.right.right = Node(50) return test_tree
def tree_b(): test_tree = BinaryTree() test_tree.root = Node(150) test_tree.root.left = Node(101) test_tree.root.left.left = Node(75) test_tree.root.left.right = Node(161) test_tree.root.left.right.left = Node(125) test_tree.root.left.right.right = Node(176) test_tree.root.right = Node(250) test_tree.root.right.left = Node(201) test_tree.root.right.right = Node(350) test_tree.root.right.right.left = Node(301) test_tree.root.right.right.right = Node(500) return test_tree
def tree_a(): test_tree = BinaryTree() test_tree.root = Node(150) test_tree.root.left = Node(100) test_tree.root.left.left = Node(75) test_tree.root.left.right = Node(160) test_tree.root.left.right.left = Node(125) test_tree.root.left.right.right = Node(175) test_tree.root.right = Node(250) test_tree.root.right.left = Node(200) test_tree.root.right.right = Node(350) test_tree.root.right.right.left = Node(300) test_tree.root.right.right.right = Node(500) return test_tree
def test_two_matches(): tree1 = BinarySearchTree() node1 = Node(5) node2 = Node(1) node3 = Node(3) node4 = Node(7) node5 = Node(9) tree1.root = node1 node1.left = node3 node1.right = node4 node3.left = node2 node4.right = node5 tree2 = BinarySearchTree() node1 = Node(6) node2 = Node(7) node3 = Node(8) node4 = Node(4) node5 = Node(5) tree2.root = node1 node1.right = node2 node1.left = node5 node2.right = node3 node5.left = node4 actual = tree1.tree_intersection(tree2) expected = [5,7] assert actual == expected