示例#1
0
        //Static helper function to create a random tree of random depth.
        public static BinaryTree CreateRandomTree(int max = 15)
        {
            Random r = new Random();
            int numToInsert = r.Next(max * 2);
            BinaryTree bt = new BinaryTree(r.Next(max));

            for (int i = 0; i < numToInsert; i++)
                bt.Insert(r.Next(max));

            return bt;
        }
示例#2
0
        //A static helper function which creates a tree guaranteed to have
        //several sequences adding to the number 6.
        public static BinaryTree CreateTest1()
        {
            BinaryTree bt = new BinaryTree(6);
            bt.Insert(8);
            bt.Insert(-5);
            bt.Insert(-3);
            bt.Insert(7);
            bt.Insert(3);
            bt.Insert(1);
            bt.Insert(4);
            bt.Insert(3);

            return bt;
        }