O(m + n)是否等于(O(max(m,n))? [英] Is O(m+n) the same as (O(max(m,n))?

查看:85
本文介绍了O(m + n)是否等于(O(max(m,n))?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有两个变量,例如m和n,并且我的算法的时间复杂度为O(m + n),则O(m,n)与具有O(max(m,n))相同吗?,你能解释为什么吗?

If I have two variables,say m and n,and my algorithm has time complexity O(m+n),is O(m,n) the same as having O(max(m,n))?If yes,can you explain why?

推荐答案

是.因为O(m + n)总是小于O(2(m + n)),所以O(m + n)与O(m + n)仅相差一个常数因数,并且max(m + n)<2(m + n).那只是分析它的一种方式.

Yes. Because O(m+n) is always smaller than O(2(m+n)), which only differs by a constant factor from O(m+n), and max(m+n) < 2(m+n). That's just one way to analyze it.

这篇关于O(m + n)是否等于(O(max(m,n))?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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