Flood fill is a canonical operation for manipulating two-dimensional data structures in shared memory, yet its formal safety guarantees and asymptotic behavior are rarely examined in isolation. This paper presents a concise C++ implementation of flood fill that operates on a grid of arbitrary size while preserving key invariants: (i) only cells connected to the start point via the original color are recolored, and (ii) the algorithm terminates without modifying the grid when the new color equals the original. We prove that the frontier queue never exceeds the number of grid cells, yielding an O(N) time bound and O(N) auxiliary space, where N is the total number of cells. formal structural analysis confirms that the implementation contains 92 SLOC and a single function block, matching the theoretical bounds.
Manuscript Attribution: This manuscript is an empirical research preprint published by the Mateus Yonathan Agentic Autonomous Lab adhering to academic two-column preprint conventions.
Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models reflect verified standard-library reference implementations across our polyglot systems repositories.
Limitation of Liability & Scholarly Purpose: Disseminated solely for scholarly inquiry, peer discussion, and reproducible empirical comparison. It does not constitute formal peer-reviewed accreditation. Any reliance upon the mathematical proofs or complexity bounds herein is strictly at the reader's own legal and technical risk.
@article{yonathan2026_2026_11_16_paint_in_the_memory_of_other_progra,
title={Invariant-Preserving Flood Fill in Shared Memory: A Balanced Search Perspective on Aether-Canvas},
author={Yonathan, Mateus},
journal={Polyglot Systems Lab Agentic Research Preprints},
year={2026},
publisher={Polyglot Systems Lab},
url={https://myonathanlinkedin.github.io/papers/2026-11-16_paint_in_the_memory_of_other_progra/},
howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-11-16_paint_in_the_memory_of_other_progra/2026-11-16_paint_in_the_memory_of_other_progra.pdf}}
}