使用猜测/验证方法查找算法的下界

发布于 2024-09-24 09:15:40 字数 605 浏览 0 评论 0原文

我试图对算法复杂性进行一些猜测,但是每次我尝试使用指数时间进行猜测时,我的猜测/验证方法似乎都会失败。我确信我正在做一些荒谬的错误,我只是自己找不到它。

例如,如果我有递归 T(n) = 2T(n-1) + T(n-2) + 1其中 T(1) = 0 和 T(2 ) = 1。

通过迭代几次并插入值 n=3,4,5,6,7,8...,我们可以观察到,对于 n>=8 的任何值,T(n) > 。 2^n,因此 2^n 不是上限。

所以,知道这些信息后,我尝试猜测 T(n)=O(2^n)

T(n) <= 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)

C(2^n)-C(2 ^n+2^(n-2)) >= 1

C(-2^(n-2)) >= 1

C >= 1/(2^(n-2)) |当n->无穷大,表达式变为零,

这是否意味着我的猜测太高了?然而,我知道事实并非如此。谁能看出我到底在哪里破坏了这个理论?谢谢。

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.

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.

So, knowing that information I try to guess that T(n)=O(2^n)

T(n) <= 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)

C(2^n)-C(2^n+2^(n-2)) >= 1

C(-2^(n-2)) >= 1

C >= 1/(2^(n-2)) | as n-> infinity, the expression goes to zero

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感性不性感 2024-10-01 09:15:40

2T(n-1)+T(n-2)+1 <= C(2^n)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)

请注意,2C(2^(n-1))=C(2^n),因此它必须是 2C(2^(n-1))+C(2^( n-2))+1 >= c(2^n)

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.
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).

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).

小清晰的声音 2024-10-01 09:15:40

我认为Itay输入后你的代数是正确的,但你对c >= 1/(2^(n-2))的理解是错误的。

你是对的,因为 n -->无穷大,然后1/(2^(n-2)) --> 0 。然而,这并不意味着c --> 0,表明你的猜测太大了。相反,这表明c >= 0。因此,c 可以是任何正常数,这意味着您的猜测是严格的。

I think your algebra is correct after Itay's input, but your understanding of c >= 1/(2^(n-2)) is wrong.

You're right that as n --> infinity, then 1/(2^(n-2)) --> 0. However, that doesn't mean that c --> 0, suggesting that your guess is too high. Rather this suggests that c >= 0. Therefore, c can be any positive constant and implies that your guess is tight.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文