Connectivity
The algorithm spreads through 4-directional or 8-directional neighbors that share the same initial property.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
The Flood Fill algorithm identifies and changes the color of a connected region in a multi-dimensional array. It's the foundation for "Paint Bucket" tools and area detection in computer vision.
The algorithm spreads through 4-directional or 8-directional neighbors that share the same initial property.
Typically implemented via DFS, each call handles one pixel and triggers neighbors until a boundary is hit.
Crucial for preventing infinite loops: check if the cell is out of bounds or already colored with the replacement.
Flood fill can also be implemented using a Queue (BFS), which spreads in levels rather than deep paths.