Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            TreeNode n1 = new TreeNode (1);
            TreeNode n2 = new TreeNode (2);
            TreeNode n3 = new TreeNode (3);
            TreeNode n4 = new TreeNode (4);
            TreeNode n5 = new TreeNode (5);
            TreeNode n6 = new TreeNode (6);

            n1.left = n2;
            n1.right = n5;

            n2.left = n3;
            n2.right = n4;

            n5.right = n6;

            TreeOp o = new TreeOp ();
            //			o.Flatten (n1);
            o.Flatten3 (n1);

            var tmp = n1;
            while (tmp != null) {
                Console.WriteLine (tmp.val);
                tmp = tmp.right;
            }

            //			Console.WriteLine ("");
            //			var e = o.LevelOrder (n1);
            //			Console.WriteLine ("");

            //			o.PrintBst (n1);
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            TreeNode n1 = new TreeNode(1);
            TreeNode n2 = new TreeNode(2);
            TreeNode n3 = new TreeNode(3);
            TreeNode n4 = new TreeNode(4);
            TreeNode n5 = new TreeNode(5);
            TreeNode n6 = new TreeNode(6);

            n1.left  = n2;
            n1.right = n5;

            n2.left  = n3;
            n2.right = n4;

            n5.right = n6;

            TreeOp o = new TreeOp();

//			o.Flatten (n1);
            o.Flatten3(n1);

            var tmp = n1;

            while (tmp != null)
            {
                Console.WriteLine(tmp.val);
                tmp = tmp.right;
            }

//			Console.WriteLine ("");
//			var e = o.LevelOrder (n1);
//			Console.WriteLine ("");

//			o.PrintBst (n1);
        }