Search⌘ K
AI Features

Graph Reductions: Flood Fill

Understand how to apply graph reductions to the flood-fill problem by modeling pixels as graph vertices and connected regions as components. Explore the use of whatever-first search to efficiently recolor connected pixels. Learn practical optimizations that avoid explicit graph construction and leverage pixel colors as markers, improving algorithm runtime in C++.

Flood-fill problem using whatever-first search

One of the earliest modern examples of whatever-first search was proposed by Edward Moore in the mid-1950s. A pixel map is a two-dimensional array whose values represent colors; the individual entries in the array are called pixels, an abbreviation of picture elements. A connected region in a pixel map is a connected ...