algorithm - T(n) >= T(n-1) 总是正确的吗?

标签 algorithm big-o time-complexity

我看到了一个关于寻找排序算法复杂性的证明,它是这样说的:

Total time complexity for the algorithm = T(n-1) + T(n-2)

Thus, Total time complexity for the algorithm <= 2 * T( n-2 )

并进一步证明了某种关系。

问题:我总是可以安全地假设 T(n) >= T(n-1) 吗?当我已经在尝试证明某些算法的复杂性时,我如何才能事先提出这一主张?

最佳答案

不,您不能提出这样的 claim 。

考虑一个函数:

f(0) = 1000000! (factorial of 1000000)
f(n) = 1, for n>0

在这里,参数越大的函数的时间复杂度越小。

一切都取决于细节,特别是 - 在提供的示例中,您已经有一个声明

Total time complexity for the algorithm = T(n-1) + T(n-2)

相当于

T(n) = T(n-1) + T(n-2)

这是关于复杂性的有力声明,但假设似乎不正确

Thus, Total time complexity for the algorithm <= 2 * T( n-2 )

我们可以从中推断出

T(n) = T(n-1) + T(n-2)

那个

T(n) = T(n-1) + T(n-2) = (T(n-2) + T(n-3)) + T(n-2) >= 2 * T( n-2 )

也许声明是这样的?

Thus, Total time complexity for the algorithm >= 2 * T( n-2 )

关于algorithm - T(n) >= T(n-1) 总是正确的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18169633/

相关文章:

javascript - 对数复杂度 : Either the book has a typo or what's happening here?

c++ - 字符串操作-字符计数

dictionary - Tcl dict 未设置复杂性顺序

algorithm - 层次和相同时的递归树

algorithm - Cut-Property 是两种方式吗?

arrays - 排列数组使其在递增和递减之间交替

algorithm - 我可以使用什么算法在图像上应用鱼眼失真?

big-o - 用 big-O 证明 N^2 是 O(2^N)

algorithm - 解决重复 : T(n)=3T(n/2)+n

algorithm - 证明修改后快速排序的运行时间=O(Nk)