Example #1
0
        static void Main(string[] args)
        {
            Bogyo     root = new Bogyo(0);
            BaszoTree tree = new BaszoTree(root);

            tree.Add(10);
            tree.Add(1);
            tree.Add(15);
            tree.Add(16);
            tree.Add(111);
            tree.Add(4);
            Console.WriteLine(tree.CheckRecursive(root, 16));
            Console.ReadKey();
        }
Example #2
0
 public Bogyo Recursive(Bogyo bogyo, int value)
 {
     if (bogyo == null)
     {
         return(new Bogyo(value));
     }
     else if (value >= bogyo.Value)
     {
         return(Recursive(bogyo.right, value));
     }
     else if (value < bogyo.value)
     {
         return(Recursive(bogyo.left, value));
     }
 }
Example #3
0
 public bool CheckRecursive(Bogyo bogyo, int cucc)
 {
     if (bogyo != null)
     {
         if (root.Value == cucc)
         {
             return(true);
         }
         else
         {
             if (CheckRecursive(bogyo.Left, cucc))
             {
                 return(true);
             }
             if (CheckRecursive(bogyo.Right, cucc))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #4
0
 public BaszoTree(Bogyo root)
 {
     this.root = root;
 }
Example #5
0
 public Bogyo(int value)
 {
     this.value = value;
     left       = null;
     right      = null;
 }