s = 0
for i = 1 to n3
for j = 1 to i do
s = s + 1
what is mean by computational complexity?
s = 0
for i = 1 to n3
for j = 1 to i do
s = s + 1
what is mean by computational complexity?
Let's assume each operation i in this code takes constant time ci. Then the running time can be expressed by the sum c1 + c2 * n3 + c3 * i * n3 + c4 * i * n3. We consider constant coefficients as insignificant because they only contribute a constant value regardless of the input. This gives us Θ(1) + Θ(n3) + Θ(i * n3 + 1) + Θ(i * n3). So in this case the time complexity is Θ(n3!) which is to say this algorithm runs in factorial time.
Just calculate some values (how many times s = s + 1 is executed for each iteration of i and sum up) and see what you get:
1 + 2 + 3 + ... + n = n * (n + 1) / 2 = n^2 / 2 + n / 2 => complexity O(n^2).