Solving a recurrence relation using iteration method

爱⌒轻易说出口 提交于 2019-12-05 13:31:39

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!