Midterm | Solutions | Code (Eclipse project for testing your answers)

Scores and Graded Exams

How do I find out my score? The scores have been released on Gradescope, a website for grading course materials. If you did not receive an invitation to join Gradescope (please check your spam folder!) please contact the instructors. Log in to Gradescope to see your midterm score.

If you have questions about exactly what points you missed and why, please look over the grade and markings made by the grader, compare it with our solutions, and then contact your Section Leader if you still have any questions.

The statistics of the exam scores (to the nearest half point, out of 120) were as follows:

Mean: 83.5

Median: 85

Standard Deviation: 20

Regrade Policy

We work hard to grade consistently and correctly, but sometimes we make mistakes in grading. If you believe part of your exam was incorrectly graded, please first download the Eclipse project linked to above and run your answer. This is the easiest way to test your code. If, after running your code, you still believe your grade is incorrect, submit a regrade request for the question you believe was graded incorrectly through Gradescope. Regrade requests need to point out the aspect of the problem that was correct, but for which points were taken off. We use a detailed rubric to grade exams, so simply requesting that an incorrect answer "should be worth more points" is not likely to result in additional points.

We reserve the right to re-grade the whole exam to make sure there are no other grading issues present - this may result in a lower total score.

All midterm regrade requests must be submitted within 7 days of the day when exam scores were posted. Specifically, all regrade requests must be submitted by 10AM on Monday, August 5, 2019.

Download Your Midterm

Download your encrypted midterm: The encrypted midterms are ready to download! (If the links are not live for your exam, check back soon). You should download the exam in advance of arriving at your exam location as well as the BlueBook software. Warning: Make sure to download the correct exam - otherwise the password you are given in your exam room won't match (sad times).

Exam Type Download Links
Regular Seating Mon. 7-9PM Regular Exam
Remote or alternate 2-hour exam Alternate Exam
OAE 150% extra time OAE Exam

Test your exam: Open BlueBook and load your exam before the midterm on Monday.

Monday, July 22
Bishop Auditorium

Review Session
Friday, July 19
10:30-11:50AM PST
Gates B01 (basement)

Download BlueBook

The exam is administered on a digital tool called BlueBook. Please make sure to download and install BlueBook on your laptop before the exam.

Note: If you're using a Mac and you get an error saying that the Disk Image is from an unidentified developer, don't panic! Simply open up the Mac-BlueBook-1.1.0.dmg file in your finder, and right click it and select "Open."" The same window will pop up, but this time you'll have a chance to open it anyway. On Windows, if you get a message that says, "Windows protected your PC," you can click on "More info" and then "Run anyway."

A practice exam that can be run on BlueBook can be downloaded below. This exam will be run under timed conditions, and give you an idea of what to expect for the actual exam.

Should you run into any technical issues, post on Piazza or shoot the BlueBook team an email at


Note: We unfortunately currently don't have a way for students to access their own submissions from the electronic practice exam. If you'd like to compare your answers to the posted solutions, please make sure to copy, save, or otherwise keep your answers before submitting. Apologies for some of the growing pains as we develop all of the functionality of our new electronic exam system!

Section Handouts and CodeStepByStep lecture practice problems (on the schedule page) are also great ways to practice relevant material.

What to Bring

The exam is on your computer but otherwise closed-book and closed-notes. You should bring:

  1. Your laptop and charger

  2. The device you use for two-step authentication

  3. Two double-sided sheets of physical notes (handwritten, or typed + printed)

  4. A power strip / extension cord (optional, but recommended if you have access to one)

If you don't have a working laptop let us know AS SOON AS POSSIBLE and we will get you set up with one.


Material Covered

The midterm will cover all material up to the midterm (the Breakout assignment and all lectures/sections the week of July 15). This includes the following concepts listed below. Note that you may be asked to read code (look at a piece of existing code and answer questions about it, such as writing its output) and/or write code (write a piece of code such as a method or short program that solves a given problem).

The following concepts will NOT be tested on the midterm:

Exam Strategies

Hopefully you have been keeping up in lecture and doing well on the assignments, but may be unsure of how to make sure your skills will translate well to the exam setting. The practice midterm above gives an idea of what to expect, but we also want to provide some general advice for how to prepare and approach the exam.

The Rationale Behind Computer Exams

You will be taking your exam using software called BlueBook. Electronic exams hold several advantages. For students, writing code on a computer (with syntax highlighting, undo, cut, etc) is a much easier exam experience than writing solutions out by hand. The way in which you are assessed is much closer to the way in which you program. The logistics become much easier for students with disability accommodations and students who are taking the course from off campus. On our end, it makes it a lot easier to make, distribute and grade exams. Instead of using the 16,000 pages of paper that CS106A typically consumes each year we use 0. Finally, grading hand written exams is hard and inaccurate. Hand written exams allow for bias in teachers' grading and are inaccurate because we can’t run your programs. Your midterm will still be assessed by a human, but they will be better equipped to understand what you were trying to do.

Great it’s on a computer! Why can’t I run my program? In a time-restricted situation, immediate feedback from the compiler can be more of an impediment than an advantage. Imagine this, you read the first problem, have a good idea how to solve it, write your solution, and trace its operation and feel good. You compile and test it. Suppose it exhibits a bug—even though it may only be a minor issue, you can see your answer is wrong—so you hunker down and rework and retest until perfect... even if it takes the whole exam. Bad deal – since you never got to the other problems on the exam! We want you to write your best answer and move on.

We know that BlueBook is not the same as working with a compiler, and we account for that in how we design and grade the exam. We are assessing your ability to think logically and use appropriate problem-solving techniques. We expect you to express yourself in reasonably correct Java, but we will be lenient with errors that are syntactic rather than conceptual.

How to Prepare for the Exam

Make a cheatsheet, but don't depend on it. We allow two double-sided "cheatsheets" of notes during the exam. Making a cheatsheet involves a thorough review of all course material, which will make you better consolidate information and identify gaps in your understanding. However, we don’t expect you to memorize minute details and the exam will not focus on them. To do well, you must be experienced at working through problems efficiently and accurately, without needing to repeatedly refer to your cheatsheets.

Practice, practice, practice. A good way to study for the programming problems is to take a problem (lecture or section example, chapter exercise, sample exam problem) and write out your solution under test-like conditions (e.g., on blank paper or a text editor not in Eclipse, with a short amount of time). Don't fall into the trap of just practicing your exam problems in Eclipse, which compiles your code and provides immediate feedback that you won't have on the real exam. You want to practice under real exam conditions to become comfortable writing code in a timed setting. This is much more valuable than simply reviewing the exam, looking at the answers, and understanding why they are correct - a much different (and simpler) task than having to write the solutions yourself.

Get your questions answered. If there is a concept you’re a bit fuzzy on, or you’d like to check your answer to something, or you wonder why a solution is written a particular way, swing by the LaIR, come to office hours, find Sarai or Laura before/after lecture, or email your Section Leader/grader; we are happy to help.

How to Take the Exam

Scan the entire exam first. Quickly peruse all questions before starting on any one. This allows you to “multitask” — while working on one problem, your mind can be brainstorming strategies or ideas for another problem in the background. You can also sketch out how to allocate your time between questions in the first pass. Speaking of which...

Spend your time wisely. There are only a handful of questions, and each is worth a significant amount. Don’t get stuck on any particular problem. There is much opportunity for partial credit, so it’s better to make good efforts on all problems than to perfect an answer to one leaving others untouched.

Consider the point value of each question. Divide the total minutes by the total number of points to figure the time per point and use that as guide when allocating your time across the problems. You may want to reserve a little time for checking your work at the end as well.

Style and decomposition are secondary to correctness. Unlike the assignments where we hold you to high standards in all areas, for an exam, unless a question explicitly says otherwise, your responses will only be graded on functionality. Decomposition and style are thus somewhat de-emphasized. However, good design may make it easier for you to get the functionality correct and require less code, which takes less time and has fewer opportunities for errors. Moreover, when a solution is incorrect, good stylistic practices such as commenting may help us determine what you were trying to do and award partial credit.

Answer in pseudo-code, but only if you must. If the syntax of Java is somehow in your way, you can answer in pseudo-code ("code-like English") for a very small amount of partial credit. There is a wide variation in the scoring for pseudo-code. Some pseudo-code is vague and content-less and does little more than restate the problem description, and thus is worth next to nothing. The more details it provides, the better. But truthfully, very good pseudo-code contains so much information that it typically would have been easier and more concise to just write in Java in the first place.

Pay attention to specific instructions. A problem statement may include detailed constraints and hints such as “Karel must end up facing East.” You may want to underline or highlight these instructions to be sure you don’t overlook them. These constraints are not there to make things more difficult; typically we are trying to guide you in the direction of a straightforward and simple solution. If you disregard these instructions, you are likely to lose points, either for not meeting the problem specification and/or for errors introduced when attempting a more difficult alternative.

Syntax is not that important if it is clear what you mean. We won't trouble you about most small syntax errors (forgetting semi-colons, misspellings, etc.) as long as your intentions are clear. Having said that, if your syntax errors cause ambiguity, we might not get the correct meaning. For example, if we see a for statement followed by two lines, where both lines are vaguely indented or a third line has been added in after the fact, but you forgot curly braces, we may be confused. If there are braces around all the lines, it will be clear you intended both to be a part of the loop body, but without the braces, we can’t be sure and it may make your answer incorrect.

Comment out abandoned attempts rather than deleting them. As it usually turns out on a CS exam, you will have false starts on a problem — you try one strategy and hit a dead end. You try something else and then realize you actually were closer to the right solution the first time. If you haven’t erased your first attempt, you can always go back to it. Once you work out a better answer, comment out your earlier attempt. When you comment out work, please direct us to which solution you want graded instead. If you forget to comment out your bad attempt and hence appear to have two answers, we reserve the right to pick which one to grade.

Save a little time for checking your work. Before submitting your exam, reserve a few minutes to go back over your work. Check for missing initialization/return statements, correct parameters passed to functions, etc. You might save yourself a few lost points by tidying up the details at the end.

Download the exam ahead of time. The exam will be posted Sunday night. Download the encrypted exam before you come to the midterm so that you are ready to go when the test starts.

Prepare your laptop. We will have outlets available, but not nearly enough for everyone. Come with a laptop that has enough battery for 2 hours. If you need battery it would be useful for you to bring your own power strip. Make sure your computer isn’t just about to run out of memory.

Final Thoughts

Always remember why you are at school. Learning and education tend to be a more fulfilling goal than just high grades. If you work hard, study lots, and feel good about your understanding of computer science, that is an achievement to be proud of in itself — regardless of how many points you get relative to the other students in the class. Moreover, for most (if not all) of you, this is your first exam ever in computer science; taking an exam in a brand-new subject doesn't happen very often! Use this first and foremost as a "litmus test" of sorts to see how you are doing midway through the class, what you are understanding well, and what you can improve in future homework assignments and on the final exam. The midterm is not worth a huge chunk of your grade, and there is still plenty of time to improve. Remember that computer science is not an easy endeavor, even for experienced computer scientists.

You can do it!