Midterm, CMSC 3140, Fall 2026
Name ______________________________________
- The weight for each question is given.
- Please write your answers on the supplied blank paper, do not write on this page other than your name.
- Please label your answers with the question number.
- Please answer each question thoughtfully and carefully.
- Please staple this page on top of your answers.
- Your answers should reflect the material presented in this class.
- Performance
- [8 points] Why is wall clock time a poor indicator of algorithm performance? Provide at least three reasons.
- Given $O(g(n)) = \{f(n) \exists ~ c>0, ~ n_0 > 0, \text{ such that } f(n) \le c g(n) ~ \forall ~n \ge n_0\}$
- [3 points] What is the purpose of the $n_0$ term?
- [3 points] Is $n^2 = O(n)$? Justify your answer.
- [3 points] Is $n = O(n^2)$? Justify your answer.
- [3 points] Is $\log_4n = O(\log_2 n)$? Justify your answer.
- Recurrence Relations
- [8 points] Derive a closed form for T(n) = 2T(n/2) + 1, for n>1, T(n) = 1 for n = 1. Show all work. (Be careful, you have NOT seen this.)
- [2 points] What is the asymptotic performance of the equation in part A?
- Given the following algorithm to check to see if an array A is in order
CHECK(A)
- for i = 2 to A.size
- if A[i] < A[i-1]
- return false
- return true
- [4 points] Trace check on the array A={1,3, 5, 8, 7}
- [4 points] Describe what CHECK at a high level.
- [4 points] Provide a loop invariant for this algorithm
- [4 points] Argue the algorithm is correct
- [4 points] What is the performance of this algorithm? Justify your answer.