Ejemplo n.º 1
0
class TestCTPMI_16_17(unittest.TestCase):

    def setUp(self):
        self.bst = BSTWithDFS()
        for n in [20, 10, 30, 5, 15, 3, 7, 17]:
            self.bst.insert(n)

    def test_case_01(self):
        node = self.bst.find_preorder(5)
        self.assertEqual(node.data, 5)
        self.assertEqual(node.left.data, 3)
        self.assertEqual(node.right.data, 7)

    def test_case_02(self):
        node = self.bst.find_inorder(30)
        self.assertEqual(node.data, 30)
        self.assertIsNone(node.left)
        self.assertIsNone(node.right)

    def test_case_03(self):
        node = self.bst.find_postorder(5)
        self.assertEqual(node.data, 5)
        self.assertEqual(node.left.data, 3)
        self.assertEqual(node.right.data, 7)
Ejemplo n.º 2
0
 def setUp(self):
     self.bst = BSTWithDFS()
     for n in [20, 10, 30, 5, 15, 3, 7, 17]:
         self.bst.insert(n)