the new element into a new subset containing only the new element. In a disjoint-set forest, MakeSet initializes the node's parent pointer and the node's size or rank. If a root is represented by a node that points to itself, then adding an element can be described using the following pseudocode: function MakeSet(x) is if x is not already in the forest then x.parent := x x.size := 1 // if nodes store size x.rank := 0 // if nodes store rank end if end function This operation has constant time complexity. In particular, initializing a disjoint-set forest with nodes requires time. In practice, MakeSet must be preceded by an operation that allocates memory to hold . As long as memory allocation is an amortized constant-time operation, as it is for a good dynamic array implementation, it does not change the asymptotic performance of the random-set forest. Finding set representatives The Find operation follows the chain of parent pointers from a specified query node until it reaches a root element. This root element represents the set to which belongs and may be itself. Find returns the root element it reaches. Performing a Find operation presents an important opportunity for improving the forest. The time in a Find operation is spent chasing parent pointers, so a flatter tree leads to faster Find operations. When a Find is executed, there is no faster way to reach the root than by following each parent pointer in succession. However, the parent pointers visited during this search can be updated to point closer to the root. Because every element visited on the way to a root is part of the same set, this does not change the sets stored in the forest. But it makes future Find operations faster, not only for the nodes between the query node and the root, but also for their descendants. This updating is an important part of the disjoint-set forest's amortized performance guarantee. There are several algorithms for Find that achieve the asymptotically optimal time complexity. One family of algorithms, known as path compression, makes every node between the query node and the root point to the root. Path compression can be implemented using a simple recursion as follows: function Find(x) is if x.parent ≠ x then x.parent := Find(x.parent) return x.parent else return x end if end function This implementation makes two passes, one up the tree and