Time complexity Analysis for loop: -
why time complexity, o(n) instead of o(nlogn)? wouldn't have multiply complexity of outer loop of inner loop?
int fun(int n){ int count = 0; (int = n; > 0; /= 2) (int j = 0; j < i; j++) count += 1; return count; }
in first iteration of loop inner loop covers half of n. next iteration covers quarter, eighth, , forth. can represent coefficients function below. can see it's infinite series sums one. entire function o(n)

Comments
Post a Comment