restructure(T)
restructures the subtree T
and count(T)
counts the nodes in the subtree T
.
find
operation) instead.
Hint: where in the proof do we use that we apply path compression and how is that knowledge used?
union
, then
all operations can be shown to be amortized O(log n).
Use for instance a potential function where the potential is the
sum of potentials associated with each node, and each node x has
a potential proportional to the logarithm of the size of the tree
rooted by x.
In the analysis of find
, it is essential to distinguish between
nodes fulfilling the usual union-by-size criterion and nodes
which do not fulfill this criterion.