Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: