We are only concern with Running Time

Just skim this and move on

Optimization Of Code (BIG O).pdf

Complexity Analysis (BIG O)2.pdf

Running Time

Measuring Running Time

Calculating Complexity of Algorithm

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$

Best / Worst / Average cases

MIT_BIGo.png

MIT_BIGo2.png

Complexity Analysis

sum = 0
for i = 1 to i = n
	for j = 1 to j = n
		sum++
return sum