public void Left() { int[] preTree = { 1, 2, 3, 4, 5 }; int[] midTree = { 1, 2, 3, 4, 5 }; TreeNode tree = Coding004.Tree(preTree.ToList(), midTree.ToList()); int[] preTree2 = { 1, 2, 3, 4, 5 }; int[] midTree2 = { 5, 4, 3, 2, 1 }; TreeNode tree2 = Coding004.Tree(preTree2.ToList(), midTree2.ToList()); Coding018.Mirror(tree); Assert.Equal(JsonConvert.SerializeObject(tree2), JsonConvert.SerializeObject(tree)); }
public void Test1() { int[] preTree = { 8, 10, 11, 9, 6, 7, 5 }; //前序 int[] midTree = { 11, 10, 9, 8, 7, 6, 5 }; //中序 TreeNode tree = Coding004.Tree(preTree.ToList(), midTree.ToList()); int[] preTree2 = { 8, 6, 5, 7, 10, 9, 11 }; //前序 int[] midTree2 = { 5, 6, 7, 8, 9, 10, 11 }; //中序 TreeNode tree2 = Coding004.Tree(preTree2.ToList(), midTree2.ToList()); Coding018.Mirror(tree); Assert.Equal(JsonConvert.SerializeObject(tree2), JsonConvert.SerializeObject(tree)); }