mt2 - M IDTERM E XAMINATION 2 COMPUTER SCIENCE 61A...

Info iconThis preview shows pages 1–4. 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 DocumentRight Arrow Icon

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

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

Unformatted text preview: M IDTERM E XAMINATION 2 COMPUTER SCIENCE 61A Department of Electrical Engineering and Computer Sciences University of California, Berkeley July 29, 2010 Instructions (Read Me!) You will be given 180 minutes to complete this exam. This exam is closed book. Collaboration is not permitted. You may not use or access, or cause to be used or accessed, any reference in print or electronic form at any time during the exam, except two double-sided 8.5 11 sheets of handwritten notes having no ap- pendage. Computing, communication, and other electronic devices (except dedicated time- keepers) must be turned off. Noncompliance with these or other instructions from the teach- ing staffincluding, for example, commencing work prematurely or continuing beyond the announced stop timeis a serious violation of the Code of Student Conduct. This booklet contains 8 (eight) substantive questions, spanning pages numbered 1 through 15 including the cover page. If you find a defect in your copy, notify the staff immediately. You will also be given a list of commonly used procedures that you may find useful. Put all answers on these pages; dont hand in any stray pieces of paper. Scratch paper will be provided to you; ask for more if you run out. You may not use your own scratch paper. Please write neatly and legibly, because if we cant read it, we cant grade it . If you find one question difficult, leave it for later; start with the ones you find easier. There may be partial credit for incomplete answers; write as much of the solution as you can. When writing procedures, dont put in error checks. Assume that you will be given arguments of the correct type. Dont panic! Breathe deeply: this exam is not worth having a heart attack about. We hope you do a great job on this exam. ^ 1 LOGIN: cs61a- Scores QUESTION SCORE TOTAL POINTS 1 2 2 2 3 2 4 4 5 4 6 2 7 3 8 6 Bonus TOTAL 25 2 LOGIN: cs61a- 1 Box and Pointers What will the Scheme interpreter print in response to the last expression in the following sequence of expressions? Also, draw a box and pointer diagram for the final result for this sequence of expressions. If any expression results in an error, circle the expression that gives the error message and just write error ; you dont have to give the precise message. Hint : Itll be a lot easier if you draw the box and pointer diagram first! (define a (list (list 1) 2)) (define b (list 3 4)) (define c (append a b)) (set! b (list 4 6)) (set-cdr! a 5) (set-car! a 7) (set-car! b 6) c For reference, append is defined below: (define (append ls1 ls2) (if (null? ls1) ls2 (cons (car ls1) (append (cdr ls1) ls2)))) What does STk print?...
View Full Document

Page1 / 16

mt2 - M IDTERM E XAMINATION 2 COMPUTER SCIENCE 61A...

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

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