[UMN logo]

CSCI 5106: Programming Languages
Spring 2006, University of Minnesota
Assignment 4
Comments on Grading


General Remarks

The maximum score depended on which invariant you used. If you used the first one, this was 10, with 5 points for writing a correct program, 2 for providing a partial correctness argument, 1 for the termination argument and 2 for testing. If you used the second invariant, a correct program counted for 5.5 points and a correct partial correctness argument counted for 2.5 points.

The mean on this homework was 8.52, the standard deviation was 1.55, the median was 9.00 and the highest score was 10.


Grading Comments Related to Using the First Invariant

I will not go through details here since most of you seem to have got this one right. An important thing to note is that since the loop invariant and the method for making progress were given to you, the program was pretty much determined. The main task was thus to show that you understood how exactly this was determined. Another way to express this thought is that it was not acceptable that you wrote any old partition program. There was a specific one that was required and credit was based on whether or not you got this specific program. One common mistake was to initialize i to m. However, this will cause the invariant to break on initial entry to the loop if A[m]>v.

With regard to the partial correctness argument, noting that the property of being a permutation of the original values is invariant around the loop is quite important. Without it, the following would be a solution to the ``partition'' problem:

     for i := m to n do
        A[i] := v;
For testing, the important things to check are ones like partitioning of 1 and 2 element arrays, arrays where the pivot value is smaller than or greater than all the elements, arrays having more than one element of a given value and, that too, a value identical to v and similar such somewhat abnormal situations including at least one normal situation. It was also important to test a case where m!=0 and n!=(length(A)-1). There are also other possibilities, depending on the code you produce. Your explanation of the test cases should try to convince the reader that you have covered situations of all possible kinds.


Grading Comments Related to Using the Second Invariant

The program in this case has three loops if you did it right: one big one for the overall computation and two inside this for moving the left and right `cursors' towards each other. The details of the correctness argument are, accordingly, more tricky. For partial correctness, you would need two invariants that go with the inner loops that you then use to obtain an invariant for the outer loop. For termination, it is also necessary to argue the that the inner loops will stop. If you did this the way I would have done it, the two inner loops would have termination conditions of the form (A[i] >= v) and (A[j] <= v) respectively. To ensure termination in these cases, you would have to use the observations, stated in the assignment writeup, that A[m] <= v and A[n] >= v respectively.


Last updated on March 20, 2006 by gopalan@cs.umn.edu and xqi@cs.umn.edu