Functional Problem Solving (CSC 151 2015S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric] - [Calendar]
Current: [Assignment] [EBoard am] [EBoard pm] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards am] [EBoards pm] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2014F)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Book Office Hours] - [Issue Tracker (Course)]
Overview
When you say that you will ask about algorithms, what types of algorithms might you ask about?
I will look to see how well you write instructions for some simple task; it could be computational, it could be not-so-computational. Samples now appear under "Quiz Questions."
How do I access the class notes?
Under "Sections", click on "eboards.am" or "eboards.pm"
How do I make an appointment with you?
For normal office hours, https://rebelsky.youcanbook.me/
Outside normal office hours, or if you can't use youcanbook.me, send me email.
Can we talk a bit more about the differences and similarities between variables and parameters?
Both variables and parameters are names for things.
Parameters name the inputs to an algorithm.
Variables name the things you compute / build / extract along the way.
Make sandwich with two kinds of spreads algorithm has parameters of "Jar One", "Jar Two", "Loaf of Bread".
Along the way, we pulled out two slices, and we referred to them "the slices on the plate" That's a variable, because it's something we computed/built along the way. "The sandwich" (which we never reached) would also be a variable. So it can be a finished product or a variable.
Other parameters: The knives, the spoons, the plates
Some things are less clear: "Dominant hand"
Do we have to know the typical forms of the various parts of an algorithm?
You don't have to write them, but you do have to be able to identify them.
I might give you an algorithm and give you strange instructions like "circle the conditional; put a star next to the repetition; underline the variables"
You said "as long as there is time left in class" is a form of repetition. Isn't it also a conditional?
One of the two most typical forms of repetion is "Do THIS until THIS CONDITION HOLDS" (or "Do THIS until THIS CONDITION DOES NOT HOLD"). The other common form is "Do THIS THIS-MANY-TIMES".
Switching back to variables - Something becomes a variable when we name it midway through the algorithm, right? Like, "this pencil"
Yes.
Tell me more about subroutines
Subroutines are just other algorithms, but algorithms that are used in service of a bigger algorithm.
E.g., multiplication is just repeated addition (plus maybe subtraction), so addition is a subroutine of the multiplication algorithm.
As one of your peers suggests, most verbs are subroutines (or built in actions)
Algorithms are verbs, nouns are variables/parameters
How would you teach someone to add?
We might assume that our reader/computer can do increment (add 1) and decrement (subtract 1), and compare to 0. That suggests repeatedly increment the first and decrement the second until you reach zero.
We might assume that people know how to draw lines of a specific length and measure those lines. (Adding via number lines.)
Assume we are only dealing with one-digit numbers, look it up in a table
Do you need otherwise in conditionals?
No.
Sometimes we have requirements about inputs. E.g., Sam doesn't teach review sessions to empty classrooms.
Can we do some more examples of variables vs. parameters?
Calculate the hypotenuse of a right triangle with legs a and b. a and b are the parameters. a-squared is computed by multipliying a times itself. If we are using "a-squared" in our computation, it is effectively a variable.
; Parameters
(define a 4)
(define b 3)
; Variables, computed
(define a-squared (* a a))
(define b-squared (* b b))
(define partial-sum (+ a-squared b-squared))
(define hypotenuse (sqrt partial-sum))
Alternately
; Parameters
(define a 4)
(define b 3)
; Variables, computed
(define hyp (sqrt (+ (* a a) (* b b))))
Anything you name that isn't a parameter is a variable.
Amazingly, we try not to make variables vary within one run of an algorithm.
What should we do when you give us ambiguous instructions?
Do the best you can to interpret them; assume that I will kick myself and then accept what you've done as reasonable.
Suppose someone does not know how to add. Give them instructions for adding two positive numbers a and b. You can make "reasonable" assumptions about other knowledge. (Probably long for a quiz question.)
Give instructions to a returning Grinnell student on how to get "Out Takes" or whatever they've renamed it to.
Here is Sam's algorithm for teaching review sessions
As long as there is time left in class
Pick one of the creatures in the room, which we will call "student"
Ask student to ask you a question.
If the student does not ask a question, throw a foam ball at it
so that future students will be intimidated and know to ask questions
Otherwise
Type a lot of random text and assume that it's helpful