3 ms·
I was gonna mention this one as well! So simple and clever. I like the explanation in the case study in Sedgewick's Algorithms [1]. Compare its simplicity to
by emmanueloga_ 8y ago
I was gonna mention this one as well! So simple and clever.
I like the explanation in the case study in Sedgewick's Algorithms [1].
Compare its simplicity to connected-components [2], another elegant algorithm but with a perhaps a bit more involved implementation.
1: https://algs4.cs.princeton.edu/15uf/ https://algs4.cs.princeton.edu/15uf/
2: https://algs4.cs.princeton.edu/41graph/CC.java.html https://algs4.cs.princeton.edu/41graph/CC.java.html