Hacker News
points by fatlotus 2 days ago | 0 comments
Another option if you find yourself with this problem (flood fill, no recursion) is union find/connected components. Like the algorithm proposed in the article, you still need to store O(N) things, and runtime is still O(N).
[–] kragen 2 days ago
Runtime of union find is slightly worse than O(N). https://www2.eecs.berkeley.edu/Pubs/TechRpts/1974/28764.html
[–] fatlotus 2 days ago
Sure, but as far as "slightly" goes, it's pretty good!
[–] kragen 2 days ago
Yup.