How to determine space and time complexity of an algorithm? -
How to determine space and time complexity of an algorithm? -
i have algorithm, not sure time , space complexity. ,
for (i = 1 n ) begin r(xi) = random(o, xi, r) i++ end
what time , space complexity in above algorithm , why?
thanks
space , time complexity in proportional size of input. suppose there input array of size n
, processing each element once, time complexity o(n)
. if utilize info construction store , process intermediate results, array of size n
, space complexity o(n)
. there many notations complexity , different complexities such log n, n, n^2, n^3, n!
.
for code time complexity o(n)
, space complexity depends on whether have defined(o(n)
) r
or passed(o(1)
) parameter.
refer here more analysis of algorithms
algorithm time-complexity space-complexity
Comments
Post a Comment