Example #1
0
        BinarySearchTreePartialFunction <TDomain, TCodomain> Find(TDomain x)
        {
            if (!_used || x.Equals(_x))
            {
                return(this);
            }

            if (x.CompareTo(_x) <= 0)
            {
                if (_left == null)
                {
                    _left = new BinarySearchTreePartialFunction <TDomain, TCodomain>();
                }

                return(_left.Find(x));
            }
            else
            {
                if (_right == null)
                {
                    _right = new BinarySearchTreePartialFunction <TDomain, TCodomain>();
                }

                return(_right.Find(x));
            }
        }
Example #2
0
        BinarySearchTreePartialFunction <TDomain, TCodomain> FindMin(BinarySearchTreePartialFunction <TDomain, TCodomain> bst)
        {
            if (!IsEmpty(bst._left))
            {
                return(FindMin(bst._left));
            }

            return(bst);
        }
Example #3
0
 bool IsEmpty(BinarySearchTreePartialFunction <TDomain, TCodomain> bst)
 {
     return(bst == null || !bst._used);
 }