Flood fill algorithm

I am not able to understand the output .
Please if possible could you share the code with me of this algorithm.

hi @G_rahil
floodfill algorithm is used to fill an enclosed area. Graphics are made up of pixels, and different colors make up for different shapes. For example, suppose there is a circle. We know there is a circle, because the border of the circle had a different color than its surrounding, ie its pixels have different values than the surrounding pixels.
We can treat the pixels as nodes of a graph and perform a recursive search to fill the “surrounding” pixels with the same color as needed. We will stop if we encounter a different color, because this means we met a boundary. Now, because we need to start somewhere, and the algorithm doesnt automatically know which region we are trying to color, we have to give the starting coordinates. If we give the coordinates of “inside” the boundary, the inner region will be colored. And if we give coordinates of “outside” the boundary, outer region will be colored.
In short, whichever region the initial coordinates lie in, that region will be colored till a boundary is encountered, and a “boundary” is defined as a pixel of a different value.

I hope I have cleared any confusions you might have. Please mark the doubt as resolved in case of no further queries.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.