Study Guides (248,337)
CS 115 (14)
Midterm

# Computer science mid-term

3 Pages
254 Views

School
Department
Computer Science
Course
CS 115
Professor
Naomi Nishimura
Semester
Fall

Description
Computer science mid-term study guide - Design recipe o Contract o Purpose o Examples o Body o Tests - Conditions - Strings/symbols - Booleans - Structures - Lists/recursion - Tracing Module 1 (slide 45, 47,49) Condensed tracing is different from tracing, don’t bother with condensed tracing. (define const1 “string”) (define y 12) (define (somef x) (+ (- y x) (sqr x) (max x y) (string-length const1))) (somf 4)  (+ (- y 4) (sqr 4) (max 4y) (string-length const1))  (+(-12 4) (sqr 4)(max 4y) (string-length const1)))  (+8(sqr 4) (max 4y) (string-length const1)))  (+8 16 (max 4y)(string-length const1)))  (+8 16(max 4 12)(string-length const1)))  (+8 16 12 (string-length “string”))  (+8 16 12 6) (= “Hello” “Hello”) -> false , equal sign should not be first (+ 3 (* 3(-2))) -> -3 (+3 (* 3(+2))) -> error. + expects 2 values Strings: (string-length “elbow”) -> 5 (string-append “best” “friend” ”cs”)-> “bestfriendcs” (substring “nana” 1 3) -> “an” - Explain: 0 n (1 a 2 n 3) a 4 Predicates – always produce a boolean (string<=? “cat” “dog”) = true (check-expect (sqr 4) 16) - Check 2 things, and see if they are equal (check-within (* 2 pi) 6.28 0.01) - Your answer if not exact as the true answer - The answer 6.28 should be within 0.01 of the real answer String vs SYMBOLS - Symbol: you can’t break apart (atomic data type) - String: you can break them apart (compound data type) How to define structures (define-struct cal(month day)) ;; a cal is a structure
More Less

Related notes for CS 115
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.