is this right???
#5. Count the number of comparisons and assignments in the following:
{ Show the count for each line to the right of the code. Give a total at the end }
sum = 0; 1 assignment (duh)
for i = 1 to (n-2) 1 assignment (update 'i'), 1 comparison (have we reached the limit?)
for j = (n+10) to i 1 assignment (update 'j'), 1 comparison (have we reached the limit?)
sum = sum + 1; 1 assignment (update 'sum')
Total: 4 assignments, 2 comparisons
#6. What is the Computational Complexity of the code in #5?
( I.e. give the running time in big O )
I think it's O(n^2), since it's two nested loops, and your computation time goes up exponentially every time you nest a loop. But the -2 and +10 may change that a little...