midterm_review

midterm_review - CS1 Introduction to Computation Midterm...

Info icon This preview shows pages 1–17. Sign up to view the full content.

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 CS1: Introduction to Computation Midterm Review
Image of page 1

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

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 Midterm ... on the web site Real Soon Now Find linked from CS 1 home page – and in "schedule" section Due date: Tuesday, November 4, 5 PM – Lab 5 also due Thurs night 2am (Nov. 6) – yes, it sucks
Image of page 2
Caltech CS 1 -- Fall 2008 Midterm Five hour time limit – (it shouldn’t really take five hours) Closed book, closed interpreter No references except: – your own labs and TA's comments on them – electronic version of lecture slides – The Scheme standard (R5RS) No collaboration!
Image of page 3

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

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 Midterm Five hour time limit – OK if not consecutive five hours, BUT – cannot go to CS 1 lecture, recitation, etc. between start and finish – shouldn't take more than 4 hours
Image of page 4
Caltech CS 1 -- Fall 2008 Submission Submit electronically, plain text format Submit to CS1man as an assignment called "midterm" Don't submit e.g. PDF, Word doc Make fit into 80 columns – we have to print it out to grade it Penalties imposed for violating these rules! OK to use editor which matches parentheses – …as long as it’s not DrScheme… – e.g. emacs, gedit
Image of page 5

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

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 Grading Score between 0.0 and 6.0 No min grading
Image of page 6
Caltech CS 1 -- Fall 2008 Midterm structure Four parts to midterm: 1) Substitution model 2) Asymptotic time complexity 3) Recursion and function design 4) Higher-order procedures and abstraction Only material through Day 7. No cons/car/cdr stuff.
Image of page 7

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

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 Substitution model Thought process: 1) Is this a special form? – define , lambda , if , cond , and , or – if so, use evaluation rule for that special form
Image of page 8
Caltech CS 1 -- Fall 2008 Substitution model Thought process: 2) Otherwise: – evaluate operands – evaluate operator – apply operator to operands
Image of page 9

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

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 Apply operator to operands If built-in procedure ( + , * etc.) – just do it • Otherwise, – procedure is a lambda expression – substitute values for variables in argument list of lambda expression, into the body – evaluate the resulting expression
Image of page 10
Caltech CS 1 -- Fall 2008 Exception When do we not substitute values for variables in lambda expression? Lambda shielding
Image of page 11

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

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 define Expect that you evaluate all define s • Even e.g. (define x 2) should be evaluated Be aware of whether define is sugared or not! – if sugared, you need to explicitly desugar it – if first operand has parens, it’s sugared
Image of page 12
Caltech CS 1 -- Fall 2008 define (define x 2) – Obviously not sugared (define f (lambda (x) (* x (+ x 3)))) – First operand doesn’t have parentheses… – Not a sugared lambda expression
Image of page 13

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

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 define (define (f x) (lambda (y) (* x (+ y 3)))) – Definitely sugared! Desugars to: (define f (lambda (x) (lambda (y) (* x (+ y 3))))) – This function returns another function
Image of page 14
Caltech CS 1 -- Fall 2008 define • Evaluate: (define (f x) (+ x (* 2 x)) – Desugar to (define f (lambda (x) (+ x (* 2 x)))) – (lambda (x) …) evaluates to itself – Then bind name f to lambda expression And you're done
Image of page 15

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

View Full Document Right Arrow Icon
Caltech CS 1 -- Fall 2008 Example (define (f x) (+ (* x x) 1)) (define (g x) (f (f x))) (g 2)
Image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern