Exercise I. For each of the following three program fragments:
a. Count the number of multiplication as basic operation, and state the Big-Oh for each complexity. Prove only how did you get the big-Oh only for part 1.
b. Implement the code in the language of your choice, and find the running time for several values of n.
c. Compare the theoretical time complexity with the actual running times.
1.
NegativeSumSquare = 0;
for(i = 1; i <= n; i++)
Sum = Sum - i * i;
2.
Negative3SumSquare = 0;
for(i = 1; i <= 3*n; i++)
Negative3Sum = Negative3Sum - i*i;
3.
NegativeSubSumSquare = 0;
for(i = 1; i <= n; i++)
for(j = 1; j <=i; j++)
NegativeSubSum = NegativeSubSum - j*j;