I have a function T(n) = T(n-1) + T(n-2) + T(n-3) + 8 and T(1) = 1
I need to calculate its run-time.
My idea : Approximation Method
Worst Case :
I say that T(n-3) will be (as slow as) T(n-1)
T(n-3)=T(n-1)
T(n-2)=T(n-1)
so
T(n) = 3*T(n-1) + 8
T(n-1) = 3*T(n-2) + 8
T(n-2) = 3*T(n-3) + 8
Substituting back : T(n) = 27*T(n-3) + 104 so
n-k = 1 and n = k
Result : I'm sure 104 must not be here
Best Case
I say that T(n-1) will be (as fast as) T(n-3)
T(n-1)=T(n-3)
T(n-2)=T(n-3)
so
T(n) = 3*T(n-3) + 8
T(n-3) = 3*T(n-3) + 8
T(n-6) = 3*T(n-9) + 8
Substituting back : T(n) = 27*T(n-9) + 104 so
T(n) = 3^k*T(n-3*k) + 104 |
n-3*k = 1 and n = 3*k+1 and k = (n-1)/3
Result : T(n) = (3^(n-1)/3)*1 + 104 |
Again I'm sure 104 must not be here
so my Result must be between these 2 cases , so I say
About that 104 nr, when substituting back I noticed this growth : first 8, then 32 and then 104 so no kind of series for me... I can't write it as
formula with "k".
Please let me know if any step is false :)
thank you