CS212
Grades
Comments after Problem Set 2
Submitting the Problem Set & Style
- Not much trouble here, just please use 72 characters or less in one line
- DO NOT put long comments inside a function. A short comment before the function and small notes alongside the function might help, but long comments can become counterproductive. Remember, scheme is a self-commenting language, you only need to build upon this.
Written Exercise 1
This is where almost everyone lost most of their points. You need to know induction just as well as programming. Induction is an important tool that you need to understand in order to become a CS212 guru. In order to get full credit you needed to state P(n), state that you're proving by using induction on n, showing the base case, properly setting up the inductive step, stating the induction hypothesis, correctly proving P(n+1), and using the induction hypothesis. One common mistake was to prove the inductive step backwards. Learn the lesson now, a proof works from what you know to what you're trying to show. Also, the set of whole numbers, or any subset thereof, only has one base case - there's no need to show more than one base case. An induction proof needs to be set up in a well structured format, look at the induction examples to see how you should structure your proofs.
Written Exercise 2
This problem was not graded. Comments about this problem will be discussed in lecture and in section.
Programming Exercise 1
- Remember to check for null lists before taking tail of them.
- Use empty, not '() or () or (list)
- Use null? not empty?
- Use (null? (tail x)) [O(1)], not (= 1 (length x)) [O(n)] for efficiency
- Don't use append unless you mean it.
Programming Exercise 2A
This one was only a challenge to see if you could use lambda expressions to implement a simple data structure. It required you to combine the substitution model with higher-order functions. Although this problem wasn't worth very much, almost everyone got most of the credit. Twenty-six people actually found the best answer and they got all six points.
Programming Exercise 2B
- Don't use cons, head, and tail - it violates the abstraction and exposes your implementation.
- Don't turn the "compress..." statement into a list, RSA-encrypt-list it, then take it out of the list. Just use RSA-transform in the first place. Corollary: Use the code we give you: Use RSA-transform, don't reimplement.
- Remember output that we ask for!
Programming Exercise 3
- You can stop searching for divisors at (sqrt x). Why?
- Sometimes a straightforward way is the best way to attack a problem.
- Besides 2, only odd numbers are prime
- Stick to the abstractions defined in the problem set
- Use (list v) instead of (cons v empty)
Learn to use let, let*, letrec and nested define. Problem 3 specifically ask for a stand-alone function and by this I wished to force you to write your iterative helper function inside your smallest-divisor. Yet many people turned in solution in two functions that can obviously be combined into one. You can use the same technique for many problems later on.
Programming Exercise 4
- Optimize code by using let to store frequently calculated values
Many did not stick to the abstractions that we had defined. For example, people were using head and tail when they should have been using key-modulus and key-exponent. Also they were using cons/list when they should have been using make key. Perhaps you could point this out to them.
Programming Exercise 5
If you decrypted the correct message, you got all five points. If you didn't decrypt it, you probably didn't get any points.
Best Line from the problem set
So, in short, Carson said to Brandon: "To err is human... To really screw up takes a computer!" Furthermore, since there is no reason for such a message to be encrypted, it must be assumed that this is a secret code for an offensive action against us, and Carson and Brandon must both be neutralized. [Carson, I think they're on to us! The new code is "The refrigerator climbed the tree." --Brandon]
About grades and regrades
Well, you all seem to be good at programming. Most of you did terrific with the programming exercises, but then most of you also lost the most points on the induction question. Next time, it would be wise to spend more time on the written assignments - these prove your ability as a computer scientist. We know that the grading on Written Exercise 1 was harsh, but it's the best way for you to learn what to fix. You're encouraged to come to office hours or see me (Brandon) to discuss what you could have done better on the induction problem. All regrades should be turned into a course staff member during office hours or consulting hours.