Prelim 3 Grading Guide
Results (each x = about 5 students) :
95-100 xx 90-94 xxxxxx 85-89 xxxxxxxxxx 80-84 xxxxxxxxxxxx 75-79 xxxxxxxxxxxxxxxxx 70-74 xxxxxxxxxxxxxx 65-69 xxxxxxxxxxx 60-64 xxxxxxxxxxx 55-59 xxxxxxxxx 50-54 xxxx 45-49 xxx < 444 xxxx Median = 74
Roughly: A 85-100, B 70-80, C 45-65
Problem 1 A (10 points)
Correct:
70 30 80 50
Not changing c. -10 if that is all there is. -5 if there is an "80 50" someplace in the shown work.
70 30 70 30
Change both a and c. -5
80 50 80 50
Wrong order. -2
80 50 70 30
Problem 1b (10 points)
Correct:
11 22 1 2
Simple aritrmetic mistake. -1
11 12 1 2
Wrong alias -5
11 22 11 22
Wrong order -2
1 2 11 22
Problem 2a (10 points)
The blue/red values are worth 7 points and the schematic is worth 3 points. Correct Values:
blue 8 times and red 7 times.
-1 for
blue 7 times and red 8 times.
-2 for
(blue 9 times and red 7 times) or (blue 8 times and red 9 times)
-3 if one is right and the other is completely wrong.
Schematic is 3 points. Need a binary tree with 8 leaves. A step thru a simple n=8
example in the style of the P5 write-up is also ok.
Problem 2b (10 point)
Correct:
20 30 10 30 10 30
-3 for
20 30 10 30 10 20
-7 for
20 30 10
-5 for two lines of output but the second all wrong
20 30 10 10 10 10
-3 for extra line of output
Problem 3 (20 points)
Count how many array entries are different from their predecessor:
int n = a.length; // 2 points -2 if use n in loop but do not initialize it, int s = 1; // 3 points -2 for int s = 0; for (int k=1; k < n ; k++) // 6 points -3 if starting value wrong, -3 if last value wrong { if (a[k-1] < a[k]) // 5 points { s++; // 2 points } } return s; // 2 points
-5 for correct solutions that involve a nested loop. Other inefficiencies overlooked. -1 max for forgetting "int" in the declarations.
-2 for n without setting it to n.length
Problem 4 (20 points)
// After this loop finishes, k is the index of the first array entry that is greater than or equal to L: int k = 0; // 2 points while(a[k] < L) // 4 points -2 if > , -1 if <= k++; // 2 points // Set up the right output array int m = a.length - k; // 2 points int[] b = new int[m]; // 2 points -1 for missing new, -1 if [] missing // fill up the array for (int j=0; j < m; j++) // 3 points { b[j] = a[k]; k++; // 3 points. Note that b[j] = a[j+k] is equivalent } return b; // 2 points
extra loops are inefficient, -1. A nested loop solution = -5. Printing the values but not returning them in the required array is -14. Returning a length n array with just the >= L entries initialized is -10.
-2 for uninitialized value
-1 if j loop goes to n
-1 if m = a.lenhth-k+1
Problem 5a (6 points)
D = D98; n1 = sum(D(2,:)>32)
Also ok is
D = D98; i = find(D(2,:)>32); n1 = length(i);
-1 if D is not set up by calling D98.
-2 for missing D, i.e.,
D = D98; n1 = sum((2,:)>32)
-2 for correct loop solution.
-1 max for syntax violation, e.g., n1++, for loops with no for, missing end.
-3 if use of find mixed up
Problem 5b (6 points)
Correct:
D = D98; n2 = sum((D(1,:)-D(2,:))>20)
% or n2 = length( find( (D(1,:)-D(2,:))>20 ) )
-2 for correct loop solution.
-1 max for syntax violation, e.g., n2++, for loops with no for, missing end.
-1 if D is not set up by calling D98.
Problem 5c (8 points)
Correct:
D = D98; n3 = sum(D(1,1:363) < D(1,2:364) & D(1,2:364) < D(1,3:365) )
1 point for each correct column range (4 max),
1 point for the correct comparisons (2 max)
1 point for and
1 point for sum.
-1 if D not set up
-2 for a correct loop solution.