Esempio n. 1
0
 private void AddTo(_001_TreeNode.BineryTreeNode <T> node, T value)
 {
     if (node.CompareTo(value) > 0)
     {
         if (node.Left == null)
         {
             node.Left = new _001_TreeNode.BineryTreeNode <T>(value);
         }
         else
         {
             AddTo(node.Left, value);
         }
     }
     else
     {
         if (node.Rigth == null)
         {
             node.Rigth = new _001_TreeNode.BineryTreeNode <T>(value);
         }
         else
         {
             AddTo(node.Rigth, value);
         }
     }
 }
Esempio n. 2
0
            //Find
            private _001_TreeNode.BineryTreeNode <T> FindWithParent(T value, out _001_TreeNode.BineryTreeNode <T> parent)
            {
                _001_TreeNode.BineryTreeNode <T> current = _head;
                parent = null;

                while (current != null)
                {
                    int result = current.CompareTo(value);

                    if (result > 0)
                    {
                        parent  = current;
                        current = current.Left;
                    }
                    else if (result < 0)
                    {
                        parent  = current;
                        current = current.Rigth;
                    }
                    else
                    {
                        break;
                    }
                }

                return(current);
            }