3 ms·
the recursive "find" function on a disjoint set forest with path compression, by R.E.Tarjan. It brings tears to my eyes every time I read it. int dsf_find
by enriquto 7y ago
the recursive "find" function on a disjoint set forest with path compression, by R.E.Tarjan. It brings tears to my eyes every time I read it.
int dsf_find(int *t, int a)
{
if (a != t[a])
t[a] = dsf_find(t, t[a]);
return t[a];
}