示例#1
0
        static void Print_Trees()
        {
            var tree = new Tree();
            var rand = new Random();

            int[] t1 = new int[] { 1, 4, 5, 7, 12, 13, 15, 14, 20, 16, 26, 32, 34, 32, 33, 37, 38, 38, 40, 39, 39, 44, 43, 48, 46 };

            var count = 25;
            var range = 50;

            for (int i = 0; i < count; i++)
            {
                int key = rand.Next(0, range);
                tree.Add(key);
            }

            tree.Print();
        }
示例#2
0
        static void Print_Trees_fixed()
        {
            var tree = new Tree();

            int[] keys  = new int[] { 1, 4, 5, 7, 12, 13, 15, 14, 20, 16, 26, 32, 34, 32, 33, 37, 38, 38, 40, 39, 39, 44, 43, 48, 46 };
            int[] keys2 = new int[] { 37, 1, 40, 32, 39, 44, 13, 34, 38, 39, 43, 48, 46, 38, 7, 15, 32, 5, 12, 14, 20, 33, 4, 16, 26 };

            var count = keys.Length;

            for (int i = 0; i < count; i++)
            {
                tree.Add(keys2[i]);
            }

            tree.Print();
            foreach (var key in tree.SortedKeys())
            {
                Console.Write(key + ",");
            }
            Console.WriteLine("({0})", count);
        }
示例#3
0
 public static void Print(this Tree tree)
 {
     tree.Print(PrintStyle.Better);
 }