Flood Fill Four-Way Algorithm Complexity

后端 未结 4 1332
忘掉有多难
忘掉有多难 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:51

    The time complexity would be O(4*mn)=(mn) because each cell of matrix is processed at most 4 times. For Example, a particular cell can be called by its top, down, left or right cell.

提交回复
热议问题