CS140 Midterm 2 Grading Guide


Written Exam

  1. (14 points)
    1. (2 points) 1 point for d (map), 0 for anything else
    2. (2 points) 1 point for e (set), 0 for anything else
    3. (2 points) 0 points for anything else
    4. (2 points) 0 points for anything else else
    5. (2 points) 1 point for b (list), 0 for anything else
    6. (2 points) 0 points for anything else
    7. (2 points) 1 point for b (list), 0 for anything else

  2. (8 points) 2 points each for a, b, x, and y

  3. (6 points) 6 points for memory leak, 3 points if their answer correctly identifies that the problem is that the first allocated piece of memory is no longer accessable after the code executes, yet has not been deleted.

  4. (10 points)
    1. part a ( 5 points): 1 point each for x, newnode, y, Jackie->next, and Frank->next
    2. part b ( 5 points): 1 point each for x, newnode, y, Jackie->next, and Sue->next. Deduct 1 point if Frank->next is not null. Grade this part based on how the student answered part a. For example, if the student's answer for part a has Frank pointing to Jackie and Jackie->next being the null pointer, then give the student full marks for part b if their answer for part b is consistent with their answer to part a.

  5. (10 points) There are two possible correct answers:
    1. friend1 does not exist: In this case 4 points for saying that friend1 does not exist, 3 points for correctly stating that friends_it will point to a sentinel node, and 3 points for correctly stating that the code will seg fault when you try to insert into the set.
    2. friendsSet is a copy: 7 points for saying that it makes a copy of the set, and 3 points for identifying why that is a problem, namely that the original set does not get properly updated.

  6. (10 points) 5 points for each part. Pretty much all or nothing unless you see something for which you wish to award partial credit.

    1. The only acceptable reason for the code fragment being wrong in part a is that the pointer is uninitialized and hence they are attempting to reference the name and age fields through an invalid pointer. They do not have to mention that the code may seg fault in order to get full credit. If they say that the code will seg fault but do not explain why, then that is 0 credit. The answer needs to be explicit about why the code fragment is incorrect.
    2. The only acceptable answer is adding a "p = new Person();" statement. It's okay to modify the declaration to read Person *p = new Person(); and it's also fine to leave the () off of person (hence p = new Person;).

  7. (12 points) 4 points each. For parts a and b deduct 1 point for having extraneous constants or terms (e.g., O(.10*2n) or O(2n + n)).

    For part c the reason must reference the Big-O notations computed in parts a and b. Deduct 1 point for not referring to the Big-O running times (they don't have to explicitly say Big-O, but they must indicate what the Big-O running times were). If they mis-compute the Big-O running times for Algorithms 1 and 2 and their miscomputation has Algorithm 2 being faster than Algorithm 1, then give them full credit in part c if they say Algorithm 2 is faster than Algorithm 1.

  8. (10 points)
    1. (3 points) All or nothing
    2. (7 points)
      • 4 points for stating the Big-O running times of the two functions (2 points each).
      • 3 points for correctly stating that the algorithm with the smaller Big-O running time is the better algorithm, even if the Big-O running times they compute are wrong.

  9. (10 points)

Coding Exam

Deductions for otherwise correct programs:

  1. There is an overall deduction of 1 point for forgetting to pass any non-modified object by reference. This deduction is only applied once.
  2. There is a deduction of 1 point for using non-meaningful variable names.
  3. There may be deductions for inefficient or convoluted code.
  4. There is a 15 point deduction for a failure to use a map to store name/problem count pairs and there is a 15 point deduction for a failure to use a set to store correctly solved problems.

  1. List
  2. Contest