[英]Finding a lower bound for an algorithm using the guess/verify method
I am trying to work out a few guesses on algorithm complexity, but every time I attempt to guess using an exponential time, my guess/verify method seems to fail. 我试图对算法的复杂性做出一些猜测,但是每次我尝试使用指数时间进行猜测时,我的猜测/验证方法似乎都失败了。 I am sure I am doing something absurdly wrong, I just can't find it myself.
我确定自己做错了什么,我自己也找不到。
For Example, if I have the recurrence T(n) = 2T(n-1) + T(n-2) + 1 , where T(1) = 0 and T(2) = 1 . 例如,如果我有递归T(n)= 2T(n-1)+ T(n-2)+1 , 其中T(1)= 0且T(2)= 1 。
By iterating it a few times and plugging the vales n=3,4,5,6,7,8... we can observe that for any value of n>=8, T(n) > 2^n, therefore 2^n is not an upper bound. 通过迭代几次并插入值n = 3,4,5,6,7,8 ...我们可以观察到,对于任何值n> = 8,T(n)> 2 ^ n,因此2 ^ n不是上限。
So, knowing that information I try to guess that T(n)=O(2^n) 因此,知道这些信息后,我会尝试猜测T(n)= O(2 ^ n)
T(n) <= C(2^n) T(n)<= C(2 ^ n)
2T(n-1)+T(n-2)+1 <= C(2^n) 2T(n-1)+ T(n-2)+1 <= C(2 ^ n)
2C(2^(n-1))+C(2^(n-2))+1 <= c(2^n) 2C(2 ^(n-1))+ C(2 ^(n-2))+ 1 <= c(2 ^ n)
C(2^n)-C(2^n+2^(n-2)) >= 1 C(2 ^ n)-C(2 ^ n + 2 ^(n-2))> = 1
C(-2^(n-2)) >= 1 C(-2 ^(n-2))> = 1
C >= 1/(2^(n-2)) | C> = 1 /(2 ^(n-2))| as n-> infinity, the expression goes to zero
当n->无穷大时,表达式变为零
Wouldn't this mean that my guess is too high? 这不是说我的猜测太高了吗? However, I know that that is not the case.
但是,我知道事实并非如此。 Can anyone see where exactly am I butchering the theory?
谁能看到我到底在哪里推销理论? Thanks.
谢谢。
I think your algebra is correct after Itay's input, but your understanding of c >= 1/(2^(n-2))
is wrong. 我认为输入Itay后您的代数是正确的,但是您对
c >= 1/(2^(n-2))
理解是错误的。
You're right that as n --> infinity
, then 1/(2^(n-2)) --> 0
. 您是正确的
n --> infinity
,然后1/(2^(n-2)) --> 0
。 However, that doesn't mean that c --> 0
, suggesting that your guess is too high. 但是,这并不意味着
c --> 0
,表明您的猜测太高了。 Rather this suggests that c >= 0
. 相反,这表明
c >= 0
。 Therefore, c
can be any positive constant and implies that your guess is tight. 因此,
c
可以是任何正常数,表示您的猜测很严格。
The transition from 2T(n-1)+T(n-2)+1 <= C(2^n)
to 2C(2^(n-1))+C(2^(n-2))+1 <= c(2^n)
is wrong. 从
2T(n-1)+T(n-2)+1 <= C(2^n)
到2C(2^(n-1))+C(2^(n-2))+1 <= c(2^n)
的过渡2C(2^(n-1))+C(2^(n-2))+1 <= c(2^n)
是错误的。
if T(n) <= C(2^n)
you can infer that 2T(n-1)+T(n-2)+1 <= 2C(2^(n-1))+C(2^(n-2))+1
but not that 2C(2^(n-1))+C(2^(n-2))+1 <= c(2^n)
. 如果
T(n) <= C(2^n)
,则可以推断出2T(n-1)+T(n-2)+1 <= 2C(2^(n-1))+C(2^(n-2))+1
但不是2C(2^(n-1))+C(2^(n-2))+1 <= c(2^n)
。
Note that 2C(2^(n-1))=C(2^n)
so it must be that 2C(2^(n-1))+C(2^(n-2))+1 >= c(2^n)
. 请注意
2C(2^(n-1))=C(2^n)
因此必须为2C(2^(n-1))+C(2^(n-2))+1 >= c(2^n)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.