예제 #1
0
 public bool Add(BigInteger value)
 {
     if (root == null)
     {
         root = new BSTNode(value);
         return true;
     }
     else
         return root.Add(value);
 }
예제 #2
0
 public bool Add(BigInteger value)
 {
     if (value == this.value) {
         return false; //This line makes sure we wont get duplicates!
     }
     else if (value < this.value)
     {
         if (left == null)
         {
             left = new BSTNode(value);
             return true;
         }
         else
             return left.Add(value);
     }
     else if (value > this.value)
     {
         if (right == null)
         {
             right = new BSTNode(value);
             return true;
         }
         else
             return right.Add(value);
     }
     return false;
 }