*Running Time*
, *Memory*
, other *hardware*
or *communication time*
.We are only concern with Running Time
Optimization Of Code (BIG O).pdf
Complexity Analysis (BIG O)2.pdf
Statement | Operations | Iterations | Sub-Total (Operations x iterations) |
---|---|---|---|
1 | 2 | 1 | 2 * 1 = 2 |
2a | 1 | 1 | 1 * 1 = 1 |
2b | 1 | n | 1 * n = n |
2c | 2 | n - 1 | 2 * (n - 1) = 2n - 2 |
3 | 3 | n - 1 | 3 * (n - 1) = 3n - 3 |
4 | 1 | 1 | 1 * 1 |
$Complexity = 2 + 1 + n + 2n - 2 + 3n - 3 + 1 = 6n - 1$ |
sum = 0
for i = 1 to i = n
for j = 1 to j = n
sum++
return sum