(Only the most significant part of the expression is required)
T(n) = 3×T(n-1) T(1) = 1 |
(Only the most significant part of the expression is required)
T(n) = T(n/2) + n^{2} T(1) = 0 |
For simplicity, you can assume that: n is some power of 2, i.e.: n = 2^{k}
for (i = 0; i < N; i = i + 2) for (j = i; j < N; j++) { operation(); } |
k = 0.5; for (i = 0; i < N; i = i + k) { operation(); k = 2*k; } |
s1 = 1; s2 = 1; for (i = 1; i <= N; i++ ) { for (j = 0; j < s2; j++) { operation(); } x = s1 + s2; s1 = s2; s2 = x; } |
You will need to use this approximation formula:
Fibonacci numbers: f_{0} = 1 f_{1} = 1 f_{2} = f_{1} + f_{0} = 1 + 1 = 2 f_{3} = f_{2} + f_{1} = 2 + 1 = 3 f_{4} = f_{3} + f_{2} = 3 + 2 = 5 f_{5} = f_{4} + f_{3} = 5 + 3 = 8 f_{6} = f_{5} + f_{4} = 8 + 5 = 13 f_{7} = f_{6} + f_{5} = 13 + 8 = 21 ... You can approximate f_{k} with: f_{k} ~= φ^{k} (where φ ~= 1.618) |