Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");

            var tree = new TreeNode <int>(1)
            {
                Left = new TreeNode <int>(2)
                {
                    Left  = new TreeNode <int>(3),
                    Right = new TreeNode <int>(4),
                },
                Right = new TreeNode <int>(5)
                {
                    Right = new TreeNode <int>(6)
                },
            };

            // pre
            Console.WriteLine("-- PreIterate --");
            tree.PreIterate();
            Console.WriteLine();
            // middle
            Console.WriteLine("-- MidIterate --");
            tree.MidIterate();
            Console.WriteLine();
            // post
            Console.WriteLine("-- PostIterate --");
            tree.PostIterate();
            Console.WriteLine();

            Console.ReadLine();
        }