Up Tree Pseudo-Code
PC-Find(i : index)
r := i;
while not(up[r] = 0) do
r := up[r]
k := up[i];
while not(k = r) do
up[i] := r;
i := k;
k := up[k]
return(r)
end{Find}
W-Union(i,j : index)
// i and j are roots
wi := weight[i];
wj := weight[j];
if wi < wj then
up[i] := j;
weight[i] := wi + wj;
else
up[j] :=i;
weight[j] := wi +wj;
end{W-Union}
Previous slide
Next slide
Back to first slide
View graphic version