Flood Fill Four-Way Algorithm Complexity

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

    The complexity of the flood fill algorithm is proportional to the number of pixels in the filled area. So, if you have e.g. a square, and M is the number of pixels in the square and N is the length of the side of a square, then M = N^2 and the complexity is O(M) = O(N^2).

    By the way, this question has already been answered in a comment in Stackoverflow. See How can I improve the performance of my flood-fill routine?

提交回复
热议问题