Midterm, CMSC 3140, Fall 2026

Name ______________________________________


  1. Performance
    1. [8 points] Why is wall clock time a poor indicator of algorithm performance? Provide at least three reasons.

  2. 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\}$
    1. [3 points] What is the purpose of the $n_0$ term?
    2. [3 points] Is $n^2 = O(n)$? Justify your answer.
    3. [3 points] Is $n = O(n^2)$? Justify your answer.
    4. [3 points] Is $\log_4n = O(\log_2 n)$? Justify your answer.

  3. Recurrence Relations
    1. [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. [2 points] What is the asymptotic performance of the equation in part A?

  4. Given the following algorithm to check to see if an array A is in order
    CHECK(A)
    
    1. for i = 2 to A.size
    2. if A[i] < A[i-1]
    3. return false
    4. return true
    1. [4 points] Trace check on the array A={1,3, 5, 8, 7}
    2. [4 points] Describe what CHECK at a high level.
    3. [4 points] Provide a loop invariant for this algorithm
    4. [4 points] Argue the algorithm is correct
    5. [4 points] What is the performance of this algorithm? Justify your answer.