A Stackless Floodfill Automaton
andsoitis
55 points
24 comments
October 25, 2026
Related Discussions
Found 5 related stories in 39.1ms across 3,874 title embeddings via pgvector HNSW
- Small-Grid Wraparound Cellular Automata surprisetalk · 17 pts · November 10, 2026 · 50% similar
- The Stacks Project, Formalized in Lean namanbnsl · 79 pts · November 05, 2026 · 45% similar
- LLMs Play Zachtronics' TIS-100 fairestvalue · 35 pts · November 11, 2026 · 37% similar
- Waymo stalls in high San Francisco floodwaters during storm mikhael · 16 pts · November 19, 2026 · 37% similar
- Weight Space Misfolding mkglees · 138 pts · November 13, 2026 · 36% similar
Discussion Highlights (6 comments)
zimpenfish
Huh, that's useful because I had to write a floodfill a couple of days ago and it was a pain in the arse. I'll be converting my code to the stackless version toot sweet.
hyperhello
The algorithm uses about half a byte per pixel and saves the path it follows. That kind of implies that the stack is still there and present, it’s just bounded to the number of pixels, and could actually be modified to just use a bounded area of the heap. But conceptually it’s easier to follow the way the paper was written. Neat.
voidUpdate
How does this deal with one pixel gaps? The algorithm can enter it just fine but there's no space to go back out again, and there doesn't seem to be a system for backtracking, unless I've misunderstood the algorithm
fatlotus
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).
amelius
Curious if Claude could come up with this when asked to implement a flood fill without stack. Alas, out of tokens.
hatthew
What's the utility of this? It's arguably still using a stack, just encoded in the original data structure itself. If your original data structure somehow uses colors but is also fine with the algorithm overwriting with its own colors, I guess it works? But those are very unusual preconditions. For any real world scenario I can imagine, I feel like there's a better solution. If the colors in your original data are important, then you can't really just overwrite them and/or assume that the algorithm can use its own colors. You're going to have to add a stack. If your original data doesn't have colors, adding a stack is better than integrating metadata into the original data structure. If for some reason your original data has colors but they aren't considered important, then just remove the colors and add a stack. If your concern is about dynamic memory, preallocate static memory equal to the size of the original data structure.