Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 为什么渐近复杂性类比不起作用?_Algorithm_Time Complexity_Mergesort - Fatal编程技术网

Algorithm 为什么渐近复杂性类比不起作用?

Algorithm 为什么渐近复杂性类比不起作用?,algorithm,time-complexity,mergesort,Algorithm,Time Complexity,Mergesort,最近,我遇到了一个问题,其中的渐近复杂性被问及- T(n, n) where T(x, c) = Θ(x) for c ≤ 2, T(c, y) = Θ(y) for c ≤ 2, and T(x, y) = Θ(x + y) + T(x/2, y/2). 提出的解决方案是 We may then begin to replace T(x/2, y/2) with the recursive formula containing it: x + y x + y x + y T(x, y) =

最近,我遇到了一个问题,其中的渐近复杂性被问及-

T(n, n) where
T(x, c) = Θ(x) for c ≤ 2,
T(c, y) = Θ(y) for c ≤ 2, and
T(x, y) = Θ(x + y) + T(x/2, y/2).
提出的解决方案是

We may then begin to replace T(x/2, y/2) with the recursive formula containing it:
x + y x + y x + y
T(x, y) = c (x + y) + c(x+y)/4 + c(x+y)/8 ...
This geometric sequence is bounded from above by 2c(x + y), and is obviously
bounded from below by c(x + y). Therefore, T(x, y) is Θ(x + y), and so T(n, n)
is Θ(n).
现在我要说的是,对于合并排序类型的算法

 T(n) = T(n/2) + O(n) 
由此得到的时间复杂度为nlog(n) 我无法理解这两个问题之间的区别,根据我的类比,第一个问题也应该是nlogn。
请帮帮我,我错在哪里。

你的论点的假设是错误的。T(n)=T(n/2)+O(n)是线性的,而不是nlogn。合并排序具有递归关系T(n)=2T(n/2)+θ(n)。因子2起作用,因为如果你伸缩关系方程,你不会得到指数递减项,当因子小于2时


(注意:检查主定理,它适用于像这样的递归关系)。

你的论点的假设是有缺陷的。T(n)=T(n/2)+O(n)是线性的,而不是nlogn。合并排序具有递归关系T(n)=2T(n/2)+θ(n)。因子2起作用,因为如果你伸缩关系方程,你不会得到指数递减项,当因子小于2时

(注意:检查主定理,它适用于像这样的递归关系)