I\'ve searched but I can\'t seem to find the complexity of the Flood Fill Algorithm (Four-way ver.). What exactly is the complexity in big O notation?
In worst-case, all cells of the matrix will be covered.
In terms of complexity time, this algorithm will be equals the recursive one: O(N×M)O(N×M), where N and M are the dimensions of the input matrix. The key idea is that in both algorithms each node is processed at most once.
Please refer below link for better understaning and more cases:
https://www.hackerearth.com/practice/algorithms/graphs/flood-fill-algorithm/tutorial/