Midterm Exam, CSCI 385, Fall 2014


  1. Asymptotic Notation
    1. [2 points] State the definition of f(n) ∈ O(g(n))
    2. [1 points] is n2 + 3n +1 ∈ O(n3)?
    3. [1 points] is n2 + 3n +1 ∈ Ω(n3)?
    4. [2 points] is n2 + 3n +1 ∈ Θ(n3)?
    5. [3 points] Describe the strengths and weekness of classifying an algorithm using asymptotic notation.

  2. Lists vs arrays
    1. [4 points] What are basic operations on an ordered array/list?
    2. [3 points] What are the performance expectations for these operations on an ordered array?
    3. [3 points] What are the performance expectations for the operations on an ordered list?
    4. [4 points] Describe guidelines for selecting the proper data structure (list or array) for a problem.

  3. Polynomial Evaluation

    The array A[0..n] contains the coefficients a0, a1 ... an for the polynomial anxn+ an-1xn-1+ ... + a1x1+a0.

    1. [4 points] Give an algorithm to evaluate the polynomial at a given point (x=4 for example.)
    2. [2 point] What is the measure of the input size for your algorithm?
    3. [2 point] What is the basic operation in your algorithm?
    4. [3 points] Give an expression which represents the timing function of your algorithm, make sure to label each term of the expression with the associated line number.
    5. [2 points] What is the performance class of your algorithm?

    
    

    More questions on back.

  4. Recursion Consider the following algorithm:
    RPM(n, m, sum)
    
    1. if n = 1 then
    2. return m+sum
    3. elseif n is even then
    4. return RPM(n/2, m*2, sum)
    5. else
    6. return RPM((n-1)/2, m*2, sum+m)
    1. [2 points] What does this algorithm do?
    2. [2 points] What is the measure of the input size for this algorithm?
    3. [2 points] What is the critical operation for this algorithm?
    4. [3 points] Provide a timing function directly related to the algorithm. (Include line numbers).
    5. [3 points] Derive a closed form of the timing function. (Show steps)
    6. [2 points] What is the performance class of this algorithm?