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;
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.