Lurker News
Preferably an elegant snippet rather than an entire (well engineered) codebase.

Comments (380) 116 threads

Show all comments

Showing thread 64 of 116

enriquto#
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];
    }