CS61A_fa04_mt2_sol - Computer Science 61A, Fall 2004 Exam...

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

View Full Document Right Arrow Icon
CS61A (R. Fateman) Exam 2B Your Login : CS61a-_____ page 1 of 10 Computer Science 61A, Fall 2004 University of California, Berkeley Exam 2A November 8, 2004 8-10PM DRAFT SOLUTIONS 11/10/04 9:15AM (points in {}) This is an open-book test. You have approximately two hours to complete it. You may consult any books, notes, or other paper-based inanimate objects available to you. To avoid confusion, read the problems carefully. If you find it hard to understand a problem, read it again, and do your best to answer it. If you think you have found a typographical error come to the front or the side of the room to ask about it. It would not be fair to give you extra personalized help during the test in understanding a question, and so we won’t do it. Partial credit may be given for partially correct answers. Note that some questions on this exam offer the option to “punt”. This is a way for you to receive partial credit for recognizing that you do not know the answer. For these questions, you have two choices. You may supply an answer, which, as usual, will receive anywhere between 0% and 100% of the points depending on how correct it is. Alternatively, you may check “punt” in which case you will receive 20% of points specified in exchange for us not having to grade the question. Your exam should contain 8 problems (numbered 0 through 7) on 10 pages. Please write your answers in the spaces provided in the test. DO NOT START UNTIL WE TELL YOU TO BEGIN. 0. [1 point] Your first name _______________ Your last (family) name______________ Your Teaching Assistant’s name __________ The day and time that your discussion section meets _______________ The seat number of your seat ______. The row number (we will help you with this, later) _______ CLEARLY PRINT YOUR CS61A LOGIN ON EVERY PAGE !!!! 11/8; 9AM Question MAX POINTS YOUR POINTS punt 0 1 1 15 2 15 3 5 4 12 5 5 6 14 7 8 TOTAL 75 /5
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS61A (R. Fateman) Exam 2B Your Login : CS61a-_____ page 2 of 10 1. Here are two programs, filter and limit , along with minor variations on them. You have already seen the first version in lecture. We point out places where programs differ from earlier ones by lines marked with ;;*. (define (filter pred? L) (define (loop L) (if (null? L) '() (let ((hd (car L)) (rst (cdr L))) (if (pred? hd) (cons hd (loop rst)) (loop rst))))) (loop L)) ;; list of all elements in L less than max (define (limit L max) (filter (lambda(x)(< x max)) L)) ;;. ....................... (define (filter2 pred? L) (define (loop L) (if (null? L) '() (let ((hd (car L)) (rst (cdr L))) (if (< hd max) ;;* (cons hd (loop rst)) (loop rst))))) (loop L)) (define (limit2 L max) (filter2 (lambda(x)(< x max)) L)) ;;. ....................... (define (filter3 max L)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/23/2010 for the course CS 61A taught by Professor Harvey during the Fall '08 term at University of California, Berkeley.

Page1 / 10

CS61A_fa04_mt2_sol - Computer Science 61A, Fall 2004 Exam...

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