重写以下解决的问题以供参考:
原始问题:
T(n) = 2T(n - 1) - 1, if n > 0
1, otherwise
第一次迭代
T(n) = 2T(n - 1) - 1
T(n - 1) = 2T(n - 1 - 1) - 1
T(n - 1) = 2T(n - 2) - 1
第二次迭代
T(n) = 2(2T(n - 2) - 1) - 1
T(n) = 4T(n - 2) - 2 - 1
T(n) = 4T(n - 2) - 3
T(n - 2) = 2T(n - 2 - 1) - 1
T(n - 2) = 2T(n - 3) - 1
第3次迭代
T(n) = 4(2T(n - 3) - 1) - 3
T(n) = 8T(n - 3) - 4 - 3
T(n) = 8T(n - 3) - 7
T(n - 3) = 2T(n - 3 - 1) - 1
T(n - 3) = 2T(n - 4) - 1
第4次迭代
T(n) = 8T(n - 3) - 7
T(n) = 8(2T(n - 4) - 1) - 7
T(n) = 16T(n - 4) - 8 - 7
T(n) = 16T(n - 4) - 15
决赛桌
At k=1, T(n) = 2T(n - 1) - 1
At k=2, T(n) = 4T(n - 2) - 3
At k=3, T(n) = 8T(n - 3) - 7
At k=4, T(n) = 16T(n - 4) - 15
T(n) = 2ᴷT(n - k) - (2ᴷ - 1)
At k=n T(n) = 2ᴺT(n - n) - (2ᴺ - 1)
T(n) = 2ᴺT(0) - (2ᴺ - 1)
T(n) = 2ᴺ - (2ᴺ - 1)
T(n) = 2ᴺ - 2ᴺ + 1
T(n) = 1
答案 0 :(得分:2)
T(n)= 1的归纳证明如下:
感应开始。
什么是T(0)? 1。
归纳步骤。
假设任何n> = 0表示T(n)= 1.现在让我们看看声明是否适用于T(n + 1)。
T(n + 1)= 2 * T(n) - 1 = 2 * 1 - 1 = 1
<强>结论强>
对于所有自然n,T(n)= 1。 1是在O(1)。
您的错误。
我在计算中发现的第一个错误是:
<VirtualHost *:443>
ServerName website.com
RewriteEngine On
# When Upgrade:websocket header is present, redirect to ws
# Using NC flag (case-insensitive) as some browsers will pass Websocket
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule ^/ws/(.*) wss://localhost:8888/ws/$1 [P,L]
# All other requests go to http
ProxyPass "/" "http://localhost:8888/"
答案 1 :(得分:1)
T(n) = 2T(n-1) -1
= 2(2T(n-2)-1) - 1 = 4T(n-2)-3 = (2^2)T(n-2)-(2^2-1)
= 2(4T(n-3)-3) - 1 = 8T(n-3)-7 = (2^3)T(n-3)-(2^3-1)
...
= (2^n)T(n-n)-(2^n-1) = (2^n)1 - 2^n + 1 = 1