Your task
Find big-O upper bounds for the following code snippets. In each, assume that CODE
is something that completes in constant time (O(1)), and N is an integer value representing the problem size. State your bound in terms of N.
Write your answers in a text file (e.g., a file created with Notepad++). For each answer, explain your reasoning.
As soon as you are done with your answer for the first problem, show your answer to the instructor or a tutor to get some feedback on your approach.
Before you submit, show your work to the instructor or a tutor.
You can check your answers against the solutions.
Problem 1
Problem 2
Problem 3
Note that the inner loop is dependent on the outer loop, so the inner loop executes a different number of iterations each time it is reached. In your explanation, you should either:
- Determine how many times
CODE
executes overall (analyzing both loops together): a series sum will be helpful - State how many times on average the inner loop executes when it is reached.
Problem 4
Problem 5
This one is similar to Problem 3: the inner loop is dependent on the outer loop.
Problem 6
Note that i is doubling on each loop iteration: how does that affect the number of times the loop will execute?
Problem 7
Submitting
Upload the text file containing your answers to the Marmoset server as lab13. The server URL is