Comments on Prelim 2

Overall, students did well on the exam. If you haven't done well on a particular question, be sure to re-do it, perhaps with the help of a member of the course staff, instead of just reading the solution.

Question 1

Parts a (trace of nested loops on matrix) and c (going from continuous to discrete, linspace) were well done overall.

(b) boolean operation on chars Some students did not know that one can perform relational operations, <= and >= in this case, on chars and char variables. A version of this question was actually in Lab Exercise 10!

Question 2

This was the most challenging question on the prelim, if one judges by the per-question score. Some students produced the correct while-loop version simply by pattern matching but did not understand (could not explain) what the given code did. Some students did not understand what the given code did and wrote incorrect code. (But a third of the class did answer this question perfectly.)

The given code returns true (1) if the input vector contains at least one positive value; otherwise returns false (0). The most common errors were

Question 3 (2-d simple array and cell array)

Very well done in general! In finding the max value in a row (finding the best in a set), some students incorrectly initialized a maxSoFar as 0 or -1. 0 and -1 are not the smallest possible values--don't forget negative values. You need to initialize to the first value of the set or -Inf

Question 4 (3-d array, computing with type uint8)

This question was generally well done. Some students mishandled or ignored type uint8. Remember this: a uint8 value is capped at 255 (and the lower bound is 0). If you add two uint8 values together you may get an overflow, e.g., x=uint8(200)+uint8(100) results in x getting the value 255, not 300. Some students neglected to handle the third dimension, the multiple layers of the 3-d array. A common algorithmic error appeared in the calculation of the indices in the reduced size array: an extra loop is NOT necessary for calculating the reduced array indices from the original array indices.

Grading error: During grading, a point was deducted for assuming that the parameter P always has three layers. That point deduction was incorrect--please submit a regrade request if you lost a point due to assuming that the array has three layers. (The reason this happened was that a generic 3-d array does not necessarily have only three layers--in the third dimension there can be any number of layers and not just three. However, in the 3-d image arrays that we've dealt with, we have always seen 3-d arrays with exactly 3 layers.)

Question 5 (2-d array of chars and nested loops)

This question was generally well done. Of the algorithmic errors that we saw, the most common one was (automatically) using the nested for-loop pattern for traversing a matrix and then adding another loop to search for the first space character in a row of the matrix:
  for i=1:nr
     for j=1:nc % this loop is extraneous!
        spaceIndex = 1
        while M(i,spaceIndex) ~= ' '
            spaceIndex = spaceIndex + 1;
        end
     end
  end
You need one loop to move row to row (the outer for-loop above) and another to move through the columns as you perform the search column by column; so you already have the two loops for traversing the 2-d array. A third loop was not necessary.

Other errors include simplifying the problem by assuming that the netID has a fixed length, there's a fixed number of digits before or after the decimal place of the gpa, ..., etc.

Statisics

Max: 100
Mean: 84.6
S.Dev: 13.4
% Action to take after prelim

if  yourScore > 88

    toDo= celebrate + later look at the solution

elseif  yourScore > 70

    toDo= redo problems + later check solution

else

    toDo= meet with a course staff member to go over exam ...
          + stay caught up from now on

end