Exemple #1
0
 public void AddNode(int newData)
 {
     if (newData >= data)
     {
         if (rightBranch == null)
         {
             rightBranch = new Node(newData);
         }
         else
         {
             rightBranch.AddNode(newData);
         }
     }
     else
     {
         if (leftBranch == null)
         {
             leftBranch = new Node(newData);
         }
         else
         {
             leftBranch.AddNode(newData);
         }
     }
 }
Exemple #2
0
 public void AddData(int data)
 {
     if (root == null)
     {
         root = new Node(data);
     }
     else
     {
         root.AddNode(data);
     }
 }