洪水填充四路算法的复杂性 [英] Flood Fill Four-Way Algorithm Complexity

查看:29
本文介绍了洪水填充四路算法的复杂性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索过,但似乎找不到 Flood Fill 算法(四路版)的复杂性.大 O 表示法的复杂度到底是什么?

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?

推荐答案

时间复杂度将是 O(4*mn)=(mn) 因为矩阵的每个单元格最多被处理4次.例如,可以通过其顶部、底部、左侧或右侧单元格调用特定单元格.

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.

这篇关于洪水填充四路算法的复杂性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆