Use this question set in addition to other lecture and lab material to practice for the exam.
• This question set does not reflect the length of the exam. It is meant to make you familiar with exam-type questions.
Given two functions f(N) and g(N), we say that f(N)=O(g(N)) if and only if there are positive constants C and
N0 such that for all N≥N0, f(N) ≤ C*g(N).
2. For each code segment, provide the tightest big-Oh bounds on its time and space complexity as a function of the input size n, which is the length of aList. In each case, provide a brief explanation of your answer.
3. Show an example of code whose best-case time cost (expressed in big-Oh) is a different order than its worstcase time cost (expressed in big-Oh)
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 1 | 2 | 3 | 4 | 5 |