Link two binomial trees of the same order.

@private
@param {Node} minNodeTree The head of the first tree to link.
@param {Node} other The head of the second tree to link.
553471
function linkTrees(minNodeTree, other) {
  other.parent = minNodeTree;
  other.sibling = minNodeTree.child;
  minNodeTree.child = other;
  minNodeTree.degree++;
}
897041
@Override
    public void meld(MergeableHeap<K> other) {
        BinaryTreeSoftHeap<K> h = (BinaryTreeSoftHeap<K>) other;

        // check same comparator
        if (comparator != null) {
            if (h.comparator == null || !h.comparator.equals(comparator)) {
                throw new IllegalArgumentException("Cannot meld heaps using different comparators!");
            }
        } else if (h.comparator != null) {
            throw new IllegalArgumentException("Cannot meld heaps using different comparators!");
        }

        if (rankLimit != h.rankLimit) {
            throw new IllegalArgumentException("Cannot meld heaps with different error rates!");
        }

        // perform the meld
        mergeInto(h.rootList.head, h.rootList.tail);
        size += h.size;

        // clear other
        h.size = 0;
        h.rootList.head = null;
        h.rootList.tail = null;
    }
269743
def compare_trees(dir1, dir2):
    """"""
    paths1 = DirPaths(dir1).walk()
    paths2 = DirPaths(dir2).walk()
    return unique_venn(paths1, paths2)
738625
function(tree, n, m) {
    return tree[n].fc < tree[m].fc ||
      (tree[n].fc == tree[m].fc && zip_depth[n] <= zip_depth[m]);
}
125335
public function leftSequence($tree = [], \Closure $callback = null)
    {
        if (!$tree) {
            $tree = $this->tree;
        }

        foreach ($tree as $k => $node) {
            $nodeChild = $node['children'];
            if ($nodeChild) {
                $this->leftSequence([$nodeChild[0]]);
            }
            if ($callback) {
                call_user_func_array($callback, ['node' => $node]);
            }
            if ($nodeChild) {
                $this->leftSequence([$nodeChild[1]]);
            }
        }
    }
113107
function reindexNodes () {
  var child = this.node.firstChild;
  this._length = 0;
  
  while (child) {
    this[this._length++] = child;
    child = child.nextSibling;
  }
}
17492
void split(treeNode parent, Point newCentre, int newCentreIndex){
		
		//loop counter variable
		int i;

		//1. Counts how many points belong to the new and how many points belong to the old centre
		int nOld = 0;
		int nNew = 0;
		for(i=0;i<parent.n;i++){
			Point centre = determineClosestCentre(parent.points[i], parent.centre, newCentre);
			if(centre == newCentre){
				nNew++;
			} else {
				nOld++;
			} 
		}

		//2. initalizes the arrays for the pointer
		
		//array for pointer on the points belonging to the old centre
		Point[] oldPoints = new Point[nOld];

		//array for pointer on the points belonging to the new centre
		Point[] newPoints = new Point[nNew];

		int indexOld = 0;
		int indexNew = 0;

		for(i=0;i<parent.n;i++){
			Point centre = determineClosestCentre(parent.points[i],parent.centre,newCentre);
			if(centre == newCentre){
				newPoints[indexNew] = parent.points[i];
				newPoints[indexNew].centreIndex = newCentreIndex;
				indexNew++;
			} else if(centre == parent.centre){
				oldPoints[indexOld] = parent.points[i];
				indexOld++;
			} else {
				//printf("ERROR !!! NO CENTER NEAREST !! \n");
			}
		}

		//left child: old centre
		treeNode lc = new treeNode(nOld, oldPoints, 
						parent.centre, parent);
		/*lc.centre = parent.centre;
		lc.points = oldPoints;
		lc.n = nOld;

		lc.lc = null;
		lc.rc = null;
		lc.parent = parent;

		treeNodeTargetFunctionValue(lc);*/
		
		//right child: new centre
		treeNode rc = new treeNode(nNew, newPoints, newCentre, 
							 parent);
		/*rc.centre = newCentre;
		rc.points = newPoints;
		rc.n = nNew;

		rc.lc = null;
		rc.rc = null;
		rc.parent = parent;

		treeNodeTargetFunctionValue(rc);*/

		//set childs of the parent node
		parent.lc = lc;
		parent.rc = rc;

		//propagate the cost changes to the parent nodes
		while(parent != null){
			parent.cost = parent.lc.cost + parent.rc.cost;
			parent = parent.parent;
		}

	}
635597
double treeNodeSplitCost(treeNode node, Point centreA, Point centreB){
		//loop counter variable
		int i;
		
		//stores the cost
		double sum = 0.0;
		
		for(i=0; i<node.n; i++){
			//loop counter variable
			int l;	

			//stores the distance between p and centreA
			double distanceA = 0.0;

			for(l=0;l<node.points[i].dimension;l++){
				//centroid coordinate of the point
				double centroidCoordinatePoint;
				if(node.points[i].weight != 0.0){
					centroidCoordinatePoint = node.points[i].coordinates[l] / node.points[i].weight;
				} else {
					centroidCoordinatePoint = node.points[i].coordinates[l];
				}
				//centroid coordinate of the centre
				double centroidCoordinateCentre;
				if(centreA.weight != 0.0){
					centroidCoordinateCentre = centreA.coordinates[l] / centreA.weight;
				} else {
					centroidCoordinateCentre = centreA.coordinates[l];
				}

				distanceA += (centroidCoordinatePoint-centroidCoordinateCentre) * 
						(centroidCoordinatePoint-centroidCoordinateCentre) ;
			}

			//stores the distance between p and centreB
			double distanceB = 0.0;

			for(l=0;l<node.points[i].dimension;l++){
				//centroid coordinate of the point
				double centroidCoordinatePoint;
				if(node.points[i].weight != 0.0){
					centroidCoordinatePoint = node.points[i].coordinates[l] / node.points[i].weight;
				} else {
					centroidCoordinatePoint = node.points[i].coordinates[l];
				}
				//centroid coordinate of the centre
				double centroidCoordinateCentre;
				if(centreB.weight != 0.0){
					centroidCoordinateCentre = centreB.coordinates[l] / centreB.weight;
				} else {
					centroidCoordinateCentre = centreB.coordinates[l];
				}

				distanceB += (centroidCoordinatePoint-centroidCoordinateCentre) * 
						(centroidCoordinatePoint-centroidCoordinateCentre) ;
			}

			//add the cost of the closest centre to the sum
			if(distanceA < distanceB){
				sum += distanceA*node.points[i].weight;
			} else {
				sum += distanceB*node.points[i].weight;
			}

		}
		
		//return the total cost
		return sum;

	}
866757
private static List<JoinNode> generateInnerJoinOrdersForTree(JoinNode subTree) {
        // Get a list of the leaf nodes(tables) to permute them
        List<JoinNode> tableNodes = subTree.generateLeafNodesJoinOrder();
        List<List<JoinNode>> joinOrders = PermutationGenerator.generatePurmutations(tableNodes);
        List<JoinNode> newTrees = new ArrayList<>();
        for (List<JoinNode> joinOrder: joinOrders) {
            newTrees.add(JoinNode.reconstructJoinTreeFromTableNodes(joinOrder, JoinType.INNER));
        }
        //Collect all the join/where conditions to reassign them later
        AbstractExpression combinedWhereExpr = subTree.getAllFilters();
        List<JoinNode> treePermutations = new ArrayList<>();
        for (JoinNode newTree : newTrees) {
            if (combinedWhereExpr != null) {
                newTree.setWhereExpression(combinedWhereExpr.clone());
            }
            // The new tree root node id must match the original one to be able to reconnect the
            // subtrees
            newTree.setId(subTree.getId());
            treePermutations.add(newTree);
        }
        return treePermutations;
    }
313689
public final Node useSourceInfoIfMissingFromForTree(Node other) {
    useSourceInfoIfMissingFrom(other);
    for (Node child = first; child != null; child = child.next) {
      child.useSourceInfoIfMissingFromForTree(other);
    }

    return this;
  }
1164056
function _composeTree() {
    var this$1 = this;

    this._updateChildNodes(this.host, this._composeNode(this.host));
    var p$ = this._insertionPoints || [];
    for (var i=0, l=p$.length, p, parent; (i<l) && (p=p$[i]); i++) {
      parent = tree.Logical.getParentNode(p);
      if ((parent !== this$1.host) && (parent !== this$1)) {
        this$1._updateChildNodes(parent, this$1._composeNode(parent));
      }
    }
  }
967240
private void associateClones(Node n, Node snapshot) {
    // TODO(johnlenz): determine if MODULE_BODY is useful here.
    if (n.isRoot() || NodeUtil.isChangeScopeRoot(n)) {
      clonesByCurrent.put(n, snapshot);
    }

    Node child = n.getFirstChild();
    Node snapshotChild = snapshot.getFirstChild();
    while (child != null) {
      associateClones(child, snapshotChild);
      child = child.getNext();
      snapshotChild = snapshotChild.getNext();
    }
  }
1012367
function removeTreeRoot(heap, root, prev) {
  // Remove root from the heap
  if (root === heap.head) {
    heap.head = root.sibling;
  } else {
    prev.sibling = root.sibling;
  }

  // Reverse the order of root's children and make a new heap
  var newHead;
  var child = root.child;
  while (child) {
    var next = child.sibling;
    child.sibling = newHead;
    child.parent = undefined;
    newHead = child;
    child = next;
  }
  var newHeap = new BinomialHeap();
  newHeap.head = newHead;

  heap.union(newHeap);
}
56139
function(e, s)
                {
                    var parens = [];
                    e.tree.push(parens);
                    parens.parent = e.tree;
                    e.tree = parens;
                }
222982
static <K,V> TreeNode<K,V> rotateLeft(TreeNode<K,V> root,
                                              TreeNode<K,V> p) {
            TreeNode<K,V> r, pp, rl;
            if (p != null && (r = p.right) != null) {
                if ((rl = p.right = r.left) != null)
                    rl.parent = p;
                if ((pp = r.parent = p.parent) == null)
                    (root = r).red = false;
                else if (pp.left == p)
                    pp.left = r;
                else
                    pp.right = r;
                r.left = p;
                p.parent = r;
            }
            return root;
        }
1324693
function SHAMapTreeNodeInner(depth) {
  SHAMapTreeNode.call(this);
  this.leaves = {};
  this.type = SHAMapTreeNode.INNER;
  this.depth = depth === undefined ? 0 : depth;
  this.empty = true;
}
804897
protected Node<K, V> unionWithComparator(Node<K, V> root1, Node<K, V> root2) {
        if (root1 == null) {
            return root2;
        } else if (root2 == null) {
            return root1;
        }

        Node<K, V> newRoot;
        Node<K, V> cur;

        // find initial
        int c = comparator.compare(root1.key, root2.key);
        if (c <= 0) {
            newRoot = root1;
            root1 = unlinkRightChild(root1);
        } else {
            newRoot = root2;
            root2 = unlinkRightChild(root2);
        }
        cur = newRoot;

        // merge
        while (root1 != null && root2 != null) {
            c = comparator.compare(root1.key, root2.key);
            if (c <= 0) {
                // link as left child of cur
                if (cur.o_c == null) {
                    root1.y_s = cur;
                } else {
                    root1.y_s = cur.o_c;
                }
                cur.o_c = root1;
                cur = root1;
                root1 = unlinkRightChild(root1);
            } else {
                // link as left child of cur
                if (cur.o_c == null) {
                    root2.y_s = cur;
                } else {
                    root2.y_s = cur.o_c;
                }
                cur.o_c = root2;
                cur = root2;
                root2 = unlinkRightChild(root2);
            }
        }

        while (root1 != null) {
            // link as left child of cur
            if (cur.o_c == null) {
                root1.y_s = cur;
            } else {
                root1.y_s = cur.o_c;
            }
            cur.o_c = root1;
            cur = root1;
            root1 = unlinkRightChild(root1);
        }

        while (root2 != null) {
            // link as left child of cur
            if (cur.o_c == null) {
                root2.y_s = cur;
            } else {
                root2.y_s = cur.o_c;
            }
            cur.o_c = root2;
            cur = root2;
            root2 = unlinkRightChild(root2);
        }

        return newRoot;
    }