使用迭代方法求解递推关系
考虑这个例子:
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)
,但我无法得出任何结论。我很困惑下一步应该做什么。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的方法是合理的,但是如果您稍微不同地重写它,您就会看到该怎么做:
现在,让
k
趋于无穷大,看看会发生什么。如果您熟悉几何系列,将会有所帮助。Your approach is sound, but you'll see what to do if you rewrite it slightly differently:
Now, let
k
tend to infinity and see what happens. It would help if you're familiar with geometric series.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.
最后一行是一个 几何系列 并且有一个 公式来简化这样的总和。
What you got there in the last line is a geometric series and there is a formula to simplify such a sum.