public void TestLevelOrderWalk() { var root = TreeGenerator.GetSimpleNormalTree(); var result = TreeWalk.LevelOrderWalk(root); var actual = string.Join(" ", result); var expected = "A B C D E F G"; Assert.AreEqual(expected, actual); }
public void TestMidOrderNormal() { var root = TreeGenerator.GetSimpleNormalTree(); var result = TreeWalk.MidOrderWalk(root); var actual = string.Join(" ", result); var expected = "D B E A F C G"; Assert.AreEqual(expected, actual); root = TreeGenerator.GetSimpleTree(); result = TreeWalk.MidOrderWalk(root); actual = string.Join(" ", result); expected = "D B A G E C F"; Assert.AreEqual(expected, actual); }
public void TestPreOrderNormal() { var root = TreeGenerator.GetSimpleNormalTree(); var result = TreeWalk.PreOrderWalk(root); var actual = string.Join(" ", result); var expected = "A B D E C F G"; Assert.AreEqual(expected, actual); root = TreeGenerator.GetSimpleTree(); result = TreeWalk.PreOrderWalk(root); actual = string.Join(" ", result); expected = "A B D C E G F"; Assert.AreEqual(expected, actual); }
public void TestPostOrderRecursively() { var root = TreeGenerator.GetSimpleNormalTree(); var result = TreeWalk.PostOrderWalk(root, TreeWalk.TreeWalkType.Recursively); var actual = string.Join(" ", result); var expected = "D E B F G C A"; Assert.AreEqual(expected, actual); root = TreeGenerator.GetSimpleTree(); result = TreeWalk.PostOrderWalk(root, TreeWalk.TreeWalkType.Recursively); actual = string.Join(" ", result); expected = "D B G E F C A"; Assert.AreEqual(expected, actual); }