Ejemplo n.º 1
0
        public InfoReturn Insert(TreeElement root, TreeElement e)
        {
            if (root == null)
            {
                return(new InfoReturn(true, e));
            }

            SearchResult res = root.SearchElement(e.content);

            if (res.foundElement)
            {
                return(new InfoReturn(false, root));                  // Element found
            }
            if (res.found.content > e.content)
            {
                res.found.left = e;
            }
            else
            {
                res.found.right = e;
            }

            return(new InfoReturn(true, root));
        }
Ejemplo n.º 2
0
 public InfoReturn(bool success, TreeElement newRoot)
 {
     this.success = success;
     this.newRoot = newRoot;
 }
Ejemplo n.º 3
0
 public SearchResult(bool foundElement, TreeElement found, TreeElement previous)
 {
     this.foundElement = foundElement;
     this.found        = found;
     this.previous     = previous;
 }