This preview shows page 1-2-15-16-31-32 out of 32 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

6.001, Spring Semester, 2007—Final Exam 1MASSACHVSETTS INSTITVTE OF TECHNOLOGYDepartment of Electrical Engineering and Computer Science6.001—Structure and Interpretation of Computer ProgramsSpring Semester, 2007Final ExamClosed Book – three sheets of notesThroughout this quiz, we have set aside space in which you should write your answers. Please putall of your answers in the designated spaces, as we will look only in this space when grading.Note that any procedures or code fragments that you write will be judged not only on correctfunction, but also on clarity and good programming practice. Also note that while there may be alot of reading to do on a problem, there is relatively little code to write, so please take the time toread each problem carefully.YOUR NAME:YOUR TA:Matt BrownAustin ClementsMichael CraigStephen McCamantBrennan SherryJames WnorowskiSarah WuPART Value Grade Grader PART Value Grade Grader1 36 5 162 45 6 183 20 7 154 50TOTAL 200No grades for 6.001 will be available until May 25th. After that time, you may (1) wait until gradesare mailed by the Registrar; (2) access your grades via WEBSIS (http://student.mit.edu/), or (3)contact the course secretary, Donna Kaufman, in 38-401. No grades will be given out by phone;you must appear in person with ID if selecting the third option.Completed final exams will not be handed back to students, but will be available starting on May25th for students to look at (but not remove from) Donna Kaufman’s office, Room 38-401.6.001, Spring Semester, 2007—Final Exam 2Part 1. (36/200 points): Object oriented systemsConsider the classes below – note the methods of each class and the inheritance structure. Notethat two lines of the WORK method for an entrepreneur will be changed in the questions. You shouldbe able to answer the questions in this part just by considering the code, and using your experiencein Project 4, but in cas e you need it, we have provided some of the object oriented system code atthe end of the exam.(define (lecturer self name)(let ((root-part (root-object self)))(make-handler’lecturer(make-methods’SAY (lambda (stuff) (display stuff) (newline))’NAME (lambda () name)’WORK (lambda () (ask self ’SAY "i love to hear myself TALK"))’PLAY (lambda () (ask self ’SAY (ask self ’NAME))(ask self ’SAY " says: i have NO TIME to play")(ask self ’WORK)))root-part)))(define (professor self name)(let ((lecturer-part (lecturer self name)))(make-handler’professor(make-methods’WORK (lambda ()(ask self ’SAY (ask self ’NAME))(ask self ’SAY " says: i need to PUBLISH my research but...")(ask lecturer-part ’WORK))’NAME (lambda () ’please-call-me-PROFESSOR)’PLAY (lambda () (ask self ’SAY "now that i am TENURED i can play all i want")))lecturer-part)))(define (entrepreneur self name)(let ((lecturer-part (lecturer self name))(professor-part (professor self name)))(make-handler’entrepreneur(make-methods’WORK (lambda ()(ask self ’SAY "i’ve got this GREAT IDEA for a company!")(ask professor-part ’WORK)) ;; HERE IS WHERE WE WILL CHANGE EXPRESSIONS)professor-part lecturer-part);; AND HERE IS WHERE WE WILL CONSIDER CHANGING ORDER))(define eric (create-instance entrepreneur ’ERIC))6.001, Spring Semester, 2007—Final Exam 3In the following questions, we are going to consider some variations on the definition of an en-trepreneur.Question 1:First, suppose we evaluate(ask eric ’WORK)What is printed out on the monitor? (To save writing, it’s enough to write down only those wordsthat would app e ar in all capital letters, SUCH AS THIS. Line breaks aren’t important, but makesure the words appear in the right order.)Question 2:Now, suppose we evaluate(ask eric ’PLAY)What is printed out on the monitor?Question 3:. Now suppose we replace the last line of the WORK method for entrepreneurs with(ask self ’WORK)If we create a new instance and then (ask eric ’WORK), what gets printed out on the monitor?6.001, Spring Semester, 2007—Final Exam 4Question 4: Suppose instead that we replace the last line of the WORK method with(ask lecturer-part ’WORK)If we create a new instance and then (ask eric ’WORK), what gets printed out on the monitor?Question 5: After making the change in the previous question, if we (ask eric ’PLAY), whatgets printed out on the monitor?Question 6: Suppose that we remove the entire WORK method for entrepreneurs. Now, if wecreate a new instance and then (ask eric ’WORK), what gets printed out on the monitor?Question 7: After making the change in the previous question, if we (ask eric ’PLAY), whatgets printed out on the monitor?6.001, Spring Semester, 2007—Final Exam 5Question 8: Suppose we use the version with no WORK method for entreprenuers, but wealso change the order of inheritance to lecturer-part professor-part. Now, if we (ask eric’WORK), what gets printed out on the monitor?Question 9: After making the change in the previous question, if we (ask eric ’PLAY), whatgets printed out on the monitor?6.001, Spring Semester, 2007—Final Exam 6Part 2 (45/200 point s): A Model of the WebThe focus of this part is to model the World Wide Web using Scheme data structures.At the most basic level, a web page contains words, which we will represent by symbols.Every page also has a name, called a URL, which we will also represent by a symbol. URL symbolswill start with http:// by convention.A page also contains links. On a real web page, a link is an underlined word that points to anotherweb page. In our Scheme model, a link is represented by a tagged data abstraction containing aword (which is what’s underlined) and a URL (the page the link goes to when you click on it).A page is a tagged data abstraction containing the page’s URL and a list of the words and linkson the page. For example, here is Ben Bitdiddle’s home page:(page http://mit.edu/benbitdiddle(I am taking (link 6.001 http://sicp.mit.edu/) this semesterand I like (link Salsa http://salsa.mit.edu/) dancing.))And here is the 6.001 homepage that one of Ben’s links points to:(page http://sicp.mit.edu/(Welcome to 6.001The first project is (link here http://sicp.mit.edu/project1)))Procedures for the page and link abstractions are shown below. Note that the data argument formake-page has type List<symbol or link>.(define (make-page url data) (list ’page url data))(define (page? object) (and (pair? object) (eq? ’page (car object))))(define (page-url page) (cadr page))(define (page-data page)


View Full Document

MIT 6 001 - Final Exam

Documents in this Course
Quiz 1

Quiz 1

6 pages

Databases

Databases

12 pages

rec20

rec20

2 pages

Quiz II

Quiz II

15 pages

Streams

Streams

5 pages

Load more
Download Final 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 Final 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 Final 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?