Ejemplo n.º 1
0
 public void AddNode(int number)
 {
     if (number < this.Number)
     {
         LeftChilds++;
         if (LeftNode == null)
         {
             LeftNode = new Node(number);
         }
         else
         {
             LeftNode.AddNode(number);
         }
     }
     // skip when number == Number
     else if (number > this.Number)
     {
         RightChilds++;
         if (RightNode == null)
         {
             RightNode = new Node(number);
         }
         else
         {
             RightNode.AddNode(number);
         }
     }
 }
Ejemplo n.º 2
0
 public void AddNode(string name, T new_value)
 {
     if (new_value.CompareTo(Value) < 0)
     {
         if (LeftNode == null)
         {
             LeftNode       = new BinaryNode <T>(new_value);
             LeftNode.Value = new_value;
         }
         else
         {
             LeftNode.AddNode(name, new_value);
         }
     }
     else
     {
         if (RightNode == null)
         {
             RightNode       = new BinaryNode <T>(new_value);
             RightNode.Value = new_value;
         }
         else
         {
             RightNode.AddNode(name, new_value);
         }
     }
 }
Ejemplo n.º 3
0
 private void AddRightSide(int new_data)
 {
     if (RightNode is null)
     {
         RightNode = new TreeNode(new_data);
     }
     else
     {
         RightNode.AddNode(new_data);
     }
 }