public void Test_Generic(string tree, string expectedTree) { var root = TreeNodeHelper.BuildTree(tree); var expected = TreeNodeHelper.BuildTree(expectedTree); var sol = new Solution(); var res = sol.ConvertBST(root); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(res, expected)); }
public void Test_Generic(string strArr, string expected) { var root = TreeNodeHelper.BuildTree(strArr); var sol = new Solution(); var res = sol.SubtreeWithAllDeepest(root); var expectedTree = TreeNodeHelper.BuildTree(expected); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(res, expectedTree)); }
public void Test_Generic(string tree, int low, int high, string expectedTree) { var root = TreeNodeHelper.BuildTree(tree); var expected = TreeNodeHelper.BuildTree(expectedTree); var sol = new Solution(); var res = sol.TrimBST(root, low, high); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(res, expected)); }
public void Test_Generic(string treeStr, int val, string expectedStr) { var root = TreeNodeHelper.BuildTree(treeStr); var expected = TreeNodeHelper.BuildTree(expectedStr); var sol = new Solution(); var res = sol.SearchBST(root, val); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(res, expected)); }
public void Test_GenericStr(string treeStr, int target, string expectedStr) { var root = TreeNodeHelper.BuildTree(treeStr); var expected = TreeNodeHelper.BuildTree(expectedStr); var sol = new Solution(); var res = sol.RemoveLeafNodes(root, target); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(res, expected)); }
public void Test_Generic(string inputStr, int key, string expectedStr) { var root = TreeNodeHelper.BuildTree(inputStr); var sol = new Solution(); var res = sol.DeleteNode(root, key); var expected = TreeNodeHelper.BuildTree(expectedStr); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(res, expected)); }
public void Test_GenericStr(string treeStr, string expectedStr) { var root = TreeNodeHelper.BuildTree(treeStr); var expected = TreeNodeHelper.BuildTree(expectedStr); var sol = new Solution(); sol.RecoverTree(root); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(root, expected)); }
public void Test_Generic(string inorderStr, string postorderStr, string expectedStr) { var inorder = ArrayHelper.ArrayFromString <int>(inorderStr); var postorder = ArrayHelper.ArrayFromString <int>(postorderStr); var sol = new Solution(); var res = sol.BuildTree(inorder, postorder); var expected = TreeNodeHelper.BuildTree(expectedStr); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(res, expected)); }
public void Test_Generic(string arrStr, string expected) { var root = TreeNodeHelper.BuildTree(arrStr); Assert.IsNotNull(root); var sol = new Solution(); var res = sol.IncreasingBST(root); var expectedRoot = TreeNodeHelper.BuildTree(expected); Assert.IsTrue(TreeNodeHelper.CompareTreeNode(res, expectedRoot)); }