Beispiel #1
0
        static void Main(string[] args)
        {
            //BinarySearchTree tree = new BinarySearchTree();
            //Random random = new Random();
            //for (int i = 20; i < 30; i++)
            //    tree.Add(random.Next(i) - 15);
            //tree.LoadToFile();
            //tree.ReadFromFile();

            //Console.WriteLine(tree.DFS() + "\n-------------------------------------------");
            //tree.InOrderTraversal();
            //Console.WriteLine(tree.DFS() + "\n-------------------------------------------");
            //tree.PreOrderTraversal();
            //Console.WriteLine(tree.DFS() + "\n-------------------------------------------");
            //tree.PostOrderTraversal();
            //Console.WriteLine(tree.DFS() + "\n-------------------------------------------");

            //BinTree bin_tree = new BinTree("1(-2(8*)  1(  1 *) )  ");

            //ThreadedBinTree th_tree = new ThreadedBinTree(bin_tree);
            //th_tree.DFS();
            //Console.WriteLine("-------------------------------------------");
            //th_tree.Connections();

            BinTree bin_tree = new BinTree("1(-2(* 8(* 0))  1 )  ");

            Console.WriteLine("-------------------------------------------");
            ThreadedBinTree th_tree = new ThreadedBinTree(bin_tree);
            th_tree.DFS();
            Console.WriteLine("-------------------------------------------");
            th_tree.Connections();
            Console.WriteLine("-------------------------------------------");
        }
Beispiel #2
0
 public ThreadedBinTree(BinTree bin_tree)
 {
     if (bin_tree == null || bin_tree.Root == null)
         root = null;
     else
     {
         root = new ThreadedNode(bin_tree.Root);
         max = bin_tree.max;
         build(ref Root.left, bin_tree.Root.left);
         build(ref Root.right, bin_tree.Root.right);
         re_build();
     }
 }
Beispiel #3
0
 public void Test5()
 {
     bin_tree = new BinTree("1 ( -2 (2*)*)");
 }
Beispiel #4
0
 public void Test4()
 {
     bin_tree = new BinTree("1( -2 *)");
 }
Beispiel #5
0
 public void Test3()
 {
     bin_tree = new BinTree("1");
 }
Beispiel #6
0
 public void Test2()
 {
     bin_tree = new BinTree("*");
 }
Beispiel #7
0
 public void Test1()
 {
     bin_tree = new BinTree("1(-2(8*)  1(  1 *) )  ");
 }