24S-CS106A-Midterm-Solution

24S-CS106A-Midterm-Solution - CS106A Handout 24S Spring...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS106A Handout 24S Spring 2011 May 4 th , 2011 CS106A Midterm Examination Solution The midterms are graded, and they’re available for pickup at the Gates Building in the lobby near my office. The median grade was a 26 out of 35, and the standard deviation was 5.4. The exam was challenging and hit on all of the topics I felt are core. A majority of you did well on the exam, and a good number of you did just beautifully. The exam itself is a small but relevant part of your final grade, so those of you who didn’t fare too well are more than welcome to come by during office hours to talk about what went badly and how you might do better next time. Also, if while looking over your exam you feel that part of your exam was graded incorrectly, you should meet up with either Chris Piech or me to take a look. We have the time and the resources to make sure your work is evaluated properly. Because the exam is only worth 35 points, even a point or two is enough to make an actual difference. (Of course, this isn’t an invitation to argue over points just to gradegrub. ! Look at the solution and the criteria we used to grade, and if you see a genuine discrepancy between what happened and what should have happened, let us know about it.) 2 Solution 1: Karel the Artist public class KarelImpasto extends SuperKarel { public void run() { while (leftIsClear()) { smearPaint(); ascend(); } smearPaint(); turnAround(); } private void smearPaint() { while (noBeepersPresent()) { move(); } while (beepersPresent()) { pickBeeper(); } while (beepersInBag()) { putBeeper(); if (frontIsClear()) { move(); } } comeBack(); } private void comeBack() { turnAround(); moveToWall(); } private void ascend() { turnRight(); move(); turnRight(); } private void moveToWall() { while (frontIsClear()) { move(); } } } Several students made the reasonable assumption that the Karel world is always 6 streets tall. Fortunately, the solution then is really no simpler and no more difficult than the more general solution that doesn’t make the assumption. As a result, we’re also happy to accept: for (int i = 0; i < 5; i++) { smearPaint(); ascend(); } as the first section of the run 2 Solution 1: Karel the Artist public class KarelImpasto extends SuperKarel { public void run() { while (leftIsClear()) { smearPaint(); ascend(); } smearPaint(); turnAround(); } private void smearPaint() { while (noBeepersPresent()) { move(); } while (beepersPresent()) { pickBeeper(); } while (beepersInBag()) { putBeeper(); if (frontIsClear()) { move(); } } comeBack(); } private void comeBack() { turnAround(); moveToWall(); } private void ascend() { turnRight(); move(); turnRight(); } private void moveToWall() { while (frontIsClear()) { move(); } } } Several students made the reasonable assumption that the Karel world is always 6 streets tall. Fortunately, the solution then is really no simpler and no more difficult than the more general solution that doesn’t make the...
View Full Document

{[ snackBarMessage ]}

Page1 / 8

24S-CS106A-Midterm-Solution - CS106A Handout 24S Spring...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online