1、树类Tree

2、创建类CreateFakeTree

3、三种遍历PreOrder,InOrder,PostOrder


        public class Tree
        {
            public string Value;
            public Tree Left;
            public Tree Right;
        }

        public static Tree CreatFakeTree()
        {
            Tree tree = new Tree() {Value = "A"};
            tree.Left = new Tree()
            {
                Value = "B",
                Left = new Tree() {Value = "D", Left = new Tree() {Value = "G"}},
                Right = new Tree() {Value = "E", Right = new Tree() {Value = "H"}}
            };
            tree.Right = new Tree() {Value = "C", Right = new Tree() {Value = "F"}};

            return tree;
        }





//前序遍历
public static void PreOrder(Tree tree)
        {
            if (tree == null)
                return;

            System.Console.WriteLine(tree.Value);
            PreOrder(tree.Left);
            PreOrder(tree.Right);
        }


//中序遍历
public static void InOrder(Tree tree)
        {
            if(tree == null)
                return;

            InOrder(tree.Left);
            System.Console.WriteLine(tree.Value);
            InOrder(tree.Right);
        }

//后序遍历
public static void PostOrder(Tree tree)
        {
            if (tree == null)
                return;

            PostOrder(tree.Left);
            PostOrder(tree.Right);
            System.Console.WriteLine(tree.Value);
        }