at firstthis implementation may seem to be no better than the sequence-based data structurebut we add the following two simple heuristics to make it run faster union-by-sizewith each position pstore the number of elements in the subtree rooted at in union operationmake the root of the smaller group become child of the other rootand update the size field of the larger root path compressionin find operationfor each position that the find visitsreset the parent of to the root (see figure ( (bfigure path-compression heuristic(apath traversed by operation find on element (brestructured tree surprising property of this data structurewhen implemented using the unionby-size and path-compression heuristicsis that performing series of operations involving elements takes ( logntimewhere logn is the log-star functionwhich is the inverse of the tower-of-twos function intuitivelylogn is the number of times that one can iteratively take the logarithm (base of number before getting number smaller than table shows few sample values minimum log , table some values of logn and critical values for its inverse proposition when using the tree-based partition representation with both union-by-size and path compressionperforming series of make groupunionand find operations on an initially empty partition involving at most elements takes ( logntime although the analysis for this data structure is rather complexits implementation is quite straightforward we conclude with complete python code for the structuregiven in code fragment