private static void Main(string[] args) { var a = new Node <string>("A"); var b = new Node <string>("B"); var c = new Node <string>("C"); var d = new Node <string>("D"); var e = new Node <string>("E"); var f = new Node <string>("F"); var g = new Node <string>("G"); var h = new Node <string>("H"); a.Left = b; b.Left = d; b.Right = e; e.Right = h; a.Right = c; c.Left = f; c.Right = g; var tree = new BinTree <string>(a); Console.WriteLine(tree.InOrder()); Console.WriteLine(tree.PreOrder()); Console.WriteLine(tree.PostOrder()); Console.WriteLine(tree.Count()); var tree2 = new BinTree <string>(); tree2.Copy(tree); Console.WriteLine(tree2.InOrder()); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Adding items to the tree\n"); Node <int> tree = new Node <int>(6); tree.Left = new Node <int>(2); tree.Left.Right = new Node <int>(5); tree.Left.Right.Data = 3; tree.Right = new Node <int>(8); BinTree <int> myTree = new BinTree <int>(tree); string buffer = ""; Console.WriteLine("\nInOrder"); myTree.InOrder(ref buffer); Console.WriteLine(buffer); buffer = ""; Console.WriteLine("\nPreOrder"); myTree.PreOrder(ref buffer); Console.WriteLine(buffer); buffer = ""; Console.WriteLine("\nPostOrder"); myTree.PostOrder(ref buffer); Console.WriteLine(buffer); buffer = ""; Console.ReadKey(); }