0% found this document useful (0 votes)
43 views

Desalgo 02 - Practice - Exercises - 1

The document contains four practice exercises involving calculating time and space complexity using Big-O, Big-Omega, and Big-Theta notations. The exercises provide code snippets or equations and ask the learner to determine if statements about their complexity are true or false.

Uploaded by

naegahosh1615
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Desalgo 02 - Practice - Exercises - 1

The document contains four practice exercises involving calculating time and space complexity using Big-O, Big-Omega, and Big-Theta notations. The exercises provide code snippets or equations and ask the learner to determine if statements about their complexity are true or false.

Uploaded by

naegahosh1615
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

IT1809

Practice Exercise #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:

Procedure that sums a list of numbers Machine Configuration


• It is a Single processor machine
• It is a 32-bit Operating System machine
procedure sum(list)
• It performs sequential execution
total = 0
• It requires 1 unit of time for Arithmetic and
for i from 0 to length(list)-1
total+ = list[i] Logical operations
return total • It requires 1 unit of time for Assignment and
Return value
• It requires 1 unit of time for Read and Write
operations

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

Practice Exercise #2:

Use Big-O to determine whether the running time below is True or False. Defend your answer

1. (𝑛𝑛 + 1)3 = 𝑂𝑂(𝑛𝑛3 )


2. 𝑛𝑛3 + 20𝑛𝑛 + 1 = 𝑂𝑂(𝑛𝑛4 )
3. 𝑛𝑛2 + 2𝑛𝑛 + 1 = 𝑂𝑂(𝑛𝑛)

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

Practice Exercise #3:

Use Big-Omega to determine whether the running time below is True or False. Defend your answer

02 Practice Exercises 1 *Property of STI


Page 1 of 2
IT1809

1. 33𝑛𝑛3 + 4𝑛𝑛2 = Ω(𝑛𝑛2 )


2. 33𝑛𝑛3 + 4𝑛𝑛2 = Ω(𝑛𝑛3 )
3. 𝑛𝑛3 + 4𝑛𝑛2 = Ω(𝑛𝑛2 )

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

Practice Exercise #4:

Use Big-Theta to determine whether the running time below is True or False. Defend your answer

1. 3𝑛𝑛2 − 100𝑛𝑛 + 6 = 𝜃𝜃(𝑛𝑛)


2. 3𝑛𝑛2 − 100𝑛𝑛 + 6 = 𝜃𝜃(𝑛𝑛2 ), where 𝑐𝑐1 = 2 and 𝑐𝑐2 = 3
3. 3𝑛𝑛2 − 100𝑛𝑛 + 6 = θ(𝑛𝑛3 )

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

02 Practice Exercises 1 *Property of STI


Page 2 of 2

You might also like