Flood Fill Four-Way Algorithm Complexity

后端 未结 4 1325
忘掉有多难
忘掉有多难 2021-01-27 14:14

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?

4条回答
  •  走了就别回头了
    2021-01-27 14:31

    The time complexity of the Flood Fill algorithm should be O(m×n) , where m= no. of rows and n=no. of columns in the given matrix. Note that every element of matrix is processed at most three times. So, it boils down to O(3×mn), which eventually is same as O(mn).

提交回复
热议问题