简体   繁体   English

T(n)= T(n-1)+ O(n * n!)的渐近复杂度是多少?

[英]What is the asymptotic complexity of T(n) = T(n-1) + O(n * n!)?

What is the asymptotic complexity of T(n) = T(n-1) + O(n * n!)? T(n)= T(n-1)+ O(n * n!)的渐近复杂度是多少? A tight upper bound would suffice. 严格的上限就足够了。 I am trying to calculate the time complexity of a very elaborate recursive algorithm to find anagrams and eventually I came up on this formula (which is hopefully right). 我试图计算一个非常复杂的递归算法来查找字谜的时间复杂度,最终我想到了这个公式(希望是对的)。 You can assume that the algorithm stops when it reaches T(1). 您可以假定算法在达到T(1)时停止。

Edit: T(n) = T(n-1) + O(n * n!) equals of course O(n*n!) + O((n-1)*(n-1)!) + ... + O(1) but I don't know what to do with that. 编辑:T(n)= T(n-1)+ O(n * n!)当然等于O(n * n!)+ O((n-1)*(n-1)!)+ .. 。+ O(1),但我不知道该怎么办。

To get a rigorous understanding of what's going on, note that 为了对发生的事情有严格的了解,请注意

n * n! = (n + 1) * n! - n! = (n + 1)! - n!

Hence the original function can be rewritten as: 因此,原始函数可以重写为:

T(n) = T(n-1) + c * ((n + 1)! - n!)  where c is a constant from the O(f(n)) notation

If you expand T(n-1) etc you'll see that the factorials cancel out giving finally 如果展开T(n-1)等,将会看到阶乘抵消了

T(n) = T(0) + c * ((n + 1)! - 0!)

Hence if T(0) is constant and finite, 因此,如果T(0)是常数且有限,

T(n) = O((n + 1)!)

It's O(n*n!). 是O(n * n!)。 Each of the subsequent terms is a lower-order polynomial dominated by the leading term. 每个后续项都是由前导项主导的低阶多项式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM