def test1(self): root1 = ROOT1() SOLUTION1.recoverTree(root1) self.assertTrue(trees.equals(EXPECTED1, root1)) root2 = ROOT2() SOLUTION1.recoverTree(root2) self.assertTrue(trees.equals(EXPECTED2, root2))
def test1(self): actual1 = SOLUTION1.generateTrees(N1) self.assertEqual(len(EXPECTED1), len(actual1)) for i in range(len(EXPECTED1)): self.assertTrue(trees.equals(EXPECTED1[i], actual1[i])) actual2 = SOLUTION1.generateTrees(N2) self.assertEqual(len(EXPECTED2), len(actual2)) for i in range(len(EXPECTED2)): self.assertTrue(trees.equals(EXPECTED2[i], actual2[i]))
def test2(self): root1 = ROOT1() SOLUTION2.flatten(root1) self.assertTrue(trees.equals(EXPECTED1, root1)) root2 = ROOT2() SOLUTION2.flatten(root2) self.assertTrue(trees.equals(EXPECTED2, root2)) root3 = ROOT3() SOLUTION2.flatten(root3) self.assertTrue(trees.equals(EXPECTED3, root3))
def test1(self): self.assertTrue(trees.equals(EXPECTED1, SOLUTION1.buildTree(PREORDER1, INORDER1))) self.assertTrue(trees.equals(EXPECTED2, SOLUTION1.buildTree(PREORDER2, INORDER2)))
def test1(self): self.assertTrue( trees.equals(EXPECTED1, SOLUTION1.sortedListToBST(HEAD1))) self.assertTrue( trees.equals(EXPECTED2, SOLUTION1.sortedListToBST(HEAD2)))
def test1(self): self.assertTrue( trees.equals(EXPECTED1, SOLUTION1.sortedArrayToBST(NUMS1))) self.assertTrue( trees.equals(EXPECTED2, SOLUTION1.sortedArrayToBST(NUMS2)))