CS 211, Spring 2005
Prelim 1 grading guide
Question 1: Induction
=======================
Base Case 5 points
1 for the label
4 for proving n=0 correctly
-1 if they plugged a value into the sum from 0 to -1.
Inductive Hypothesis 3 points
-2 if they said for all n
-1 if they didn't label it
-1 if they didn't say n >= 0
(up to 3 points off)
Inductive Step 3 points
Must have used it correctly
-1 if they didn't label it
Algebra 2 points
-2 if messed up algebra very badly
-1 for minor algebra mistake
Conclusion 2 points
1 for the label
1 for a satisfactory conclusion
Common mistakes
- tried to evaluate the sum from 0 to -1.
- forgot the conclusion
- didn't assume for some n >= 0
Question 2:
=============
Each subpart was awarded 3 points as follows:
(a) 3 for "abcde"
0 otherwise
(b) 3 for "not equal"
0 otherwise
(c) 3 for "hello"
0 otherwise
(d) 3 for "012"
1 for "123"
0 otherwise
(e) 3 for "32"
0 otherwise
(f) 3 for "4"
0 otherwise
(g) 3 for "VbnC"
0 otherwise
(h) 3 for "12 13"
1 for "12 12"
1 for "13 13"
0 otherwise
Question 3:
=============
(a) 2.5 points for stating that a reference is a pointer
1 point if an example of pointer semantics is given with no/invalid
explanation
2.5 points for stating that primitive types store data directly
1 point for an example or primitive type semantics with no/invalid
explanation
(b) 2.5 points for stating that static type is known at compile time
1 point for an example, without a valid explanation
2.5 points for stating that the dynamic type is the type of an object at
runtime
1 point for an example, without a valid explanation
Common mistakes:
- only saying that a primitive type uses less memory than a reference type
- describing static variables, rather than static types.
Question 4:
=============
5 points for checking for a null (i.e. empty) tree
(-2) if only the children are checked (i.e. if tree2list(null) fails)
5 points for traversing the tree in preorder
5 points for properly building and maintaining the list
(-2.5) for losing the tail
Common mistakes:
- many people had code that simply didn't make sense. For those, we did our
best to award points where we could.
Question 5:
=============
1 point each.
Question 6:
=============
3 points for checking that the input is a String.
3 points for casting the input to a String after the dynamic check
if try/catch is used for these, only three points are awarded.
3 points for checking that the lengths are the same (this may be implicit in
the loop)
6 points for the loop:
1 point for the loop construct itself
4 points for charAt comparison, -1 point if compareTo or equals is used for
character comparison
1 point for the logic of the loop
1 point for general correctness
- 1 for syntax error or scoping error