使用迭代方法求解递推关系

发布于 2024-08-18 00:54:22 字数 324 浏览 8 评论 0 原文

考虑这个例子:

T(n) = T(7n/8) + 2n 

我假设 T(1) = 0

并尝试用以下方式解决它

T(n) = T(7n/8) + 2n
     = T(49n/64) + 2.(7n/8) + 2n
     = T(343n/512) + 2.(7n/8).(7n/8)+ 2.(7n/8) + 2n 
     = T(1) + 2n ( (7n/8)^i + ..... + 1)               

,但我无法得出任何结论。我很困惑下一步应该做什么。

Consider this example :

T(n) = T(7n/8) + 2n 

I assumed T(1) = 0

and tried to solve it in the following way

T(n) = T(7n/8) + 2n
     = T(49n/64) + 2.(7n/8) + 2n
     = T(343n/512) + 2.(7n/8).(7n/8)+ 2.(7n/8) + 2n 
     = T(1) + 2n ( (7n/8)^i + ..... + 1)               

but I could not come to any conclusion about this. I am confused about what should I do in the next step.

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

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

发布评论

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

评论(3

掩于岁月 2024-08-25 00:54:22

您的方法是合理的,但是如果您稍微不同地重写它,您就会看到该怎么做:

T(n) = T((7/8)^1 * n) + 2 * (7/8)^0 * n
     = T((7/8)^2 * n) + 2 * (7/8)^1 * n + 2 * (7/8)^0 * n
     = T((7/8)^3 * n) + 2 * (7/8)^2 * n + 2 * (7/8)^1 * n + 2 * (7/8)^0 * n
     .
     .
     .
     = T((7/8)^k * n) + 2 * n * sum j = 0 to k-1 (7/8)^j

现在,让 k 趋于无穷大,看看会发生什么。如果您熟悉几何系列,将会有所帮助。

Your approach is sound, but you'll see what to do if you rewrite it slightly differently:

T(n) = T((7/8)^1 * n) + 2 * (7/8)^0 * n
     = T((7/8)^2 * n) + 2 * (7/8)^1 * n + 2 * (7/8)^0 * n
     = T((7/8)^3 * n) + 2 * (7/8)^2 * n + 2 * (7/8)^1 * n + 2 * (7/8)^0 * n
     .
     .
     .
     = T((7/8)^k * n) + 2 * n * sum j = 0 to k-1 (7/8)^j

Now, let k tend to infinity and see what happens. It would help if you're familiar with geometric series.

吻安 2024-08-25 00:54:22

T(n) = T(7n/8) + 2n = 2n * (1 + 7/8 + (7/8)^2 + ... (7/8)^Z) + T(1) 其中 Z = ?

唯一的技巧是找到 Z。我打赌日志会有所帮助。抱歉,已经晚了,我没有思考清楚,但是......您不需要添加多个 2n。

编辑:Z 是您需要将 n 乘以 7/8 直到得到 1 的次数。

因此,n * 7^Z / 8^Z = 1

(7/8)^Z = 1/n

(8/7) ^Z = n

您想要求解 Z。

T(n) = T(7n/8) + 2n = 2n * (1 + 7/8 + (7/8)^2 + ... (7/8)^Z) + T(1) where Z = ?

The only trick is finding Z. I bet a log will help. Sorry it is late, and I am not thinking straight, but ... you should not need to add multiple 2n.

Edit: Z is how many time you need to multiply n by 7/8 until you get 1.

So, n * 7^Z / 8^Z = 1

(7/8)^Z = 1/n

(8/7)^Z = n

You want to solve for Z.

翻身的咸鱼 2024-08-25 00:54:22

最后一行是一个 几何系列 并且有一个 公式来简化这样的总和。

What you got there in the last line is a geometric series and there is a formula to simplify such a sum.

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