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)); }
public InfoReturn(bool success, TreeElement newRoot) { this.success = success; this.newRoot = newRoot; }
public SearchResult(bool foundElement, TreeElement found, TreeElement previous) { this.foundElement = foundElement; this.found = found; this.previous = previous; }