Desalgo 02 - Practice - Exercises - 1
Desalgo 02 - Practice - Exercises - 1
1. Calculate the time complexity of the example code on the right column, assuming that a model machine has the
following configuration on the left side:
2. Calculate the space complexity of the example code below, given that the data type to use is “int.” The final answer
should be converted from “byte” to “word.”
Algorithm sum(a, n)
{
s = 0;
for i = 1 to n
s = s + a[i];
return s;
}
Grading Rubric:
CRITERIA POINTS
Complete solution with the correct answer 10
Last two major steps of the solution are incorrect 8
Half of the solution is correct 6
First two major steps of the solution are correct 4
First major step of the solution is correct 2
Use Big-O to determine whether the running time below is True or False. Defend your answer
Grading Rubric:
CRITERIA POINTS
Complete solution with the correct answer 10
Last two major steps of the solution are incorrect 8
Half of the solution is correct 6
First two major steps of the solution are correct 4
First major step of the solution is correct 2
Use Big-Omega to determine whether the running time below is True or False. Defend your answer
Grading Rubric:
CRITERIA POINTS
Complete solution with the correct answer 10
Last two major steps of the solution are incorrect 8
Half of the solution is correct 6
First two major steps of the solution are correct 4
First major step of the solution is correct 2
Use Big-Theta to determine whether the running time below is True or False. Defend your answer
Grading Rubric:
CRITERIA POINTS
Complete solution with the correct answer 10
Last two major steps of the solution are incorrect 8
Half of the solution is correct 6
First two major steps of the solution are correct 4
First major step of the solution is correct 2