Unformatted text preview:

6.01, Spring Semester, 2008—Sample Midterm Exam—Distributed March 16 1MASSACHVSETTS INSTITVTE OF TECHNOLOGYDepartment of Electrical Engineering and Computer Science6.01—Introduction to EECS ISpring Semester, 2008Sample Midterm Exam—Distributed March 16Ground RulesThis is a sample midterm to help you study and to give you a sense of what kinds of problems toexpect on the real midterm. You can pick up the midterm in 34-501 (the 6.01 lab) on Wednesday,May 19, any time between 8:30AM and 7:00PM, and return it within 3 hours after you pick it up.If you plan to print out your answers (good idea) we suggest that you work out the mechanics ofhow you are going to print before you pick up the exam. “My dog ate my printer” is not a validexcuse for being late.When you pick the exam up, you’ll see the following instructions:• Read through this exam and ask any questions you have before you leave. If you find thatyou have a question after that, try to pick your own answer, and write down what assumptionyou’re making. We will not answer your questions after you’ve left the room.• Turn the exam in to room 34-501 (the 6.01 lab) at most three hours after you pick it up. Youmay turn in your solution early, but late papers will be penalized 10% of the grade value forevery ten minutes you are late.• For the problems that ask you to write Python code, you should just think it through andwrite down the code. You must not try to actually debug it (it will take too long). Don’tspend time trying to be sure the syntax is correct. It’s more important to communicate yourability to think algorithmically than to worry about the fine-grained details of syntax. Besure to add comments that explain what you’re trying to do.• We expect you to spend less than an hour per question. The extra time is to let you relaxand think.• Your answer may be handwritten or typed; it should be legible in either case. We reserve theright to refuse to grade illegible papers.• Label your answers clearly, we won’t look through long printouts for something that lookslike an answer.• You may read anything you like (labs, books, the web) during the exam, but you may notcommunicate with anyone else.• When you turn in your paper, the sheets must be stapled together and you must have yourname and section number on each sheet. Papers that do not do this will not be graded andyou will not get credit for the exam.6.01, Spring Semester, 2008—Sample Midterm Exam—Distributed March 16 2ProgrammingSoar, as you recall, contains a procedure sonarDistances(), which returns the list of distancesreported by the robot sonars. For this problem, assume that there is only one sonar, and that theprocedure readSonar() returns that sonar reading as a single number. You’ve undoubtedly noticedthat the robot sonars sometimes give flaky readings. So it might be useful to have a procedurelike readSonar, but which returns the entire history of sonar readings, or the average of the sonarreadings over several calls, or the minimum and maximum readings. In this problem, we’ll ask youto implement such a procedure. Please use only the basic functions built into Python (e.g., don’tuse fancy packages you might find on the Web).We’ll start with the following class:class Ra nge Tra cker :def __ini t__ ( self ):self . saved = []def v alues ( self ):self . saved . append ( r eadSonar ())return self . savedThe RangeTracker class behaves as follows (assuming that the first few sonar readings are 10, 9,11, and 12).>>> rt = R angeTracker ()>>> rt . values ()[10]>>> rt . values ()[10 , 9]>>> rt . values ()[10 , 9, 11]>>> rt . values ()[10 , 9, 11 , 12]6.01, Spring Semester, 2008—Sample Midterm Exam—Distributed March 16 3Question 1: Add methods to the RangeTracker class to return the maximum and minimum ofthe saved values (one method for each).Question 2: The mean, or average, of a set of N numbers x1, . . . , xNis the sum of the x’s overthe number of x’s:¯x =1NNXi=1xi.Add a method to the RangeTracker class that returns the mean of the sonar readings.Question 3: The standard deviation of a set of numbers is a measure of how spread out thenumbers are around the mean. It can be computed asvuuut1N − 1NXi=1(xi−¯x)2.Add a method to the RangeTracker class that returns the standard deviation of the sonarreadings.Question 4: Add a method to the RangeTracker class that takes a function f as an argument,and returns the mean of the values of f applied to each of the x values. That is:1NNXi=1f(xi) .Question 5: The above parts of the problem asked you to add new methods to theRangeTracker class. An alternative way to add new methods—without modifying the orig-inal class—is to use inheritance. Define a new class called TrackerWithReset, a subclassof RangeTracker, that has a reset method that reinitializes the list of saved values to theempty list.In assessing your performance on this programming problem, we’re interested not only in whetheryour programs return the right answers, but in whether your code is and shows good style. Thedefinition of “good style” is somewhat idiosyncratic, but for us, it includes things like• Do you reuse pieces of code to achieve compactness and clarity (for example, does your codefor computing the standard deviation make use of your code for computing the mean)?• Do you take advantage of list comprehension, rather than writing explicit for or while loops?It is not necessary for you to test and debug your code. We won’t be taking off points for trivialsyntax errors. Similarly, on the final exam, we may ask you to write code, but we certainly won’texpect you to run and debug it.Helpful hint: The mean of the set of numbers 1, 2, 3, . . . , 10 is 5.5, and the standard deviationis 3.02766 .6.01, Spring Semester, 2008—Sample Midterm Exam—Distributed March 16 4Feedback controlIn lab for week 6, you programmed the robot to drive down the center of a narrow corridor,maintaining a desired distance desired from the center. You used a control algorithm based on theerrore[n] = ddesired[n] − d[n] ,where d[n] is measured distance to the left of the center. You modeled the robot’s dynamics byd[n] = d[n − 1] + VδTθ[n − 1]θ[n] = θ[n − 1] + δTΩ[n − 1]where θ[n] is the angle of the robot heading, Ω[n] is the robot’s angular velocity, V is the robot’sforward speed, and δTis the time step. You then implemented a control law that produced valuesfor Ω[n].Suppose Ω[n] is


View Full Document

MIT 6 01 - Sample Midterm Exam

Documents in this Course
Week 1

Week 1

3 pages

Op-Amps

Op-Amps

8 pages

Op-Amps

Op-Amps

6 pages

Syllabus

Syllabus

14 pages

Planning

Planning

14 pages

Load more
Download Sample Midterm Exam
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Sample Midterm Exam and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Sample Midterm Exam 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?