Functional Problem Solving (CSC 151 2016S) : EBoards

CSC151.02 2016S, Review Session 1 (2016-01-28)


Overview

Background

Quiz Topics

Sample Quiz Questions

The Parts of an Algorithm

List the core building blocks of algorithms.

For each building block of algorithms, identify a corresponding part of the almond butter and preserves algorithm.

Basic Scheme: Evaluate

What output will you get when you type the following instructions?

> (+ 3 4)
7
> (define a 4)
; nothing shows up, but whenever we type `a` we get the value 4
> (* a 2)
8
> (square a)
You idiot.  square is not defined. (or some other error messsage)
> (sqrt a)
2
> (a + 5)
I'm sorry, 4 is not an operation
> (sqrt (a))
I'm sorry, 4 is not an operation.  Didn't you learn that yet?
> (+a 5)
I'm sorry, +a is not an operation.  (Or some less intuitive error
message)
> (+ a b)
We don't have b defined yet
> (string-append "a" "b")
"ab"
> (string-append a a)
4 is not a string

Basic Scheme: Write

Translate the following mathematical expressions (using PEMDAS) into Scheme form. (PEMDAS - parentheses, exponent, multiplication/division, addision/subtraction)

32 + 17 * 2 
> (+ 32 (* 17 2))

(32 + 17) * 2 
> (* (+ 32 17) 2)

32 + 17 * 2 / 4
> (+ 32 (* 17 (/ 2 4)))

32 + 18 / 2 / 4
> (+ 32 (/ 18 (/ 2 4))) ; NO
> (+ 32 (/ (/ 18 2) 4))
> (+ 32 (/ 18 2 4)) ; OKAY, BUT CONFUSING

11 + 12 + 13
> (+ 11 12 13)

Assorted Questions

What are the two meanings of "free" in "free software"?

How often do we have quizzes in this class?

How is this class likely to be different from other classes at Grinnell?

Additional Questions

Note: Ordering in Scheme is different! We do steps inside-out, rather than left-to-right (or PEMDAS or whatever)

(* 3 (+ 4 5))

How do you deal with ambiguity, such as "spread the goop", which could be either repetition ("spread the goop until evenly coated") or subroutine ("spread the goop" works for any goop)?

Fairly leniently, since there is some ambiguity involved. We often give you labels, and you use each label once.

What is the relationship between subroutines and basic operations?

Subroutines are the operations you write, basic operations are the ones the computer/language already knows.

You assume I know the basic operation "twist", from that, you build the subroutine "open jar"

You assume I know the basic operation *, from that, you build the subroutine "square"