In a disjoint-set forest, the representative of each set is the root of that set's tree . " Find " follows parent nodes until it reaches the root . " Union " combines two trees into one by attaching the root of one to the root of the other.
42.
This siftUp version can be visualized as starting with an empty heap and successively inserting elements, whereas the siftDown version given above treats the entire input array as a full but " broken " heap and " repairs " it starting from the last non-trivial sub-heap ( that is, the last parent node ).
43.
This can be interpreted as mapping the infinite depth binary tree onto this tree and then applying breadth-first search : replace the " down " edges connecting a parent node to its second and later children with " right " edges from the first child to the second child, from the second child to the third child, etc . Thus at each step one can either go down ( append a (, 1 ) to the end ) or go right ( add one to the last number ) ( except the root, which is extra and can only go down ), which shows the correspondence between the infinite binary tree and the above numbering; the sum of the entries ( minus one ) corresponds to the distance from the root, which agrees with the 2 " n " " 1 nodes at depth in the infinite binary tree ( 2 corresponds to binary ).