Exemple #1
0
 def test_1_2_returns_2_1(self):
     btree = [TreeNode(i) for i in range(1, 3)]
     btree[0].left = btree[1]
     self.assertEqual(Solution().inorder_traversal(btree[0]), [2, 1])
Exemple #2
0
 def test_1_null_2_returns_1_2(self):
     btree = [TreeNode(1), TreeNode(2)]
     btree[0].right = btree[1]
     self.assertEqual(Solution().inorder_traversal(btree[0]), [1, 2])
Exemple #3
0
 def test_1_returns_1(self):
     self.assertEqual(Solution().inorder_traversal(TreeNode(1)), [1])
Exemple #4
0
 def test_1_null_2_3_returns_1_3_2(self):
     btree = list(TreeNode(i) for i in [1, 2, 3])
     btree[0].right = btree[1]
     btree[1].left = btree[-1]
     self.assertEqual(Solution().inorder_traversal(btree[0]), [1, 3, 2])
Exemple #5
0
 def test_inorder(self):
     solution = Solution()
     tree = TreeNode(1, None, TreeNode(2, TreeNode(3)))