Midterm Exam, CSCI 385, Fall 2013


  1. Asymptotic Notation
    1. [2 points] State the definition of f(n) ∈ O(g(n))
    2. [4 points] Show that if f1(n) ∈ O(g1(n)) and f2(n) ∈ O(g2(n)), then f1(n) + f2(n) ∈ O(max(g1(n),g2(n))
    3. [2 points] What does the above property imply in terms of algorithm analysis?
  2. STOOGE_GCD: Compute the GCD of two positive integers
    1. [4 points] Is STOOGE_GCD an algorithm? Why or why not.
    2. [2 points] What design pattern is STOOGE_GCD attempting to employ?
  3. CLOSEST_PAIR: Given a set of n points P, find the closest two.
    1. [2 points] Does this algorithm terminate? (why or why not)
    2. [2 points] Does this algorithm work? (why or why not)
    3. [2 points] What is the critical operation for this algorithm?
    4. [4 points] What is the performance of this algorithm? (Give a mathematical expression and relate the lines of the instructions to the terms of the expression)
    5. [3 points] Is there a different best, worst and average case performance for this algorithm? If so, state the different values, if not, state why.
    6. [2 points] What design pattern was applied to develop this algorithm?
  4. PATTERN_MATCH: Given a text T[1..n] and a pattern P[1..m] locate the first occurrence of P in T.
    1. [2 points] Does this algorithm terminate?
    2. [2 points] Does this algorithm work?
    3. [2 points] What is the critical operation for this algorithm?
    4. [4 points] What is the performance of this algorithm? (Give a mathematical expression and relate the lines of the instructions to the terms of the expression)
    5. [3 points] Is there a different best, worst and average case performance for this algorithm? If so, state the different values, if not, state why.
  5. FLIP_IT (S): reverse a string
    1. [4 points] Build a recurrence relation to represent the performance of this algorithm. Describe how your recurrence relation relates to the algorithm (use line numbers).
    2. [4 pints] Solve the recurrence relation.