# Week 11

## Midterm 2 / Random Functions, Local Expressions, Abstraction

### Monday

- Recipe Card Check

- Assignment 4 - Permutations
- Due: Wed, April 17
- Questions?

*Exam Promises for Midterm 2*

- Handout: Fall 2017 Midterm 2
- Solutions we worked through in class: sample-exam2-sols.rkt
- Note: there will not be a question about List Expressions on tomorrow's exam since we had one on the last midterm; that question will be replaced with a list of structs question (more on that below in the promises)

- Exam Promises for Midterm 2
- 75 points / 75 minutes (but you really have the full two hours!)
- Budget your time one point per minute
- Open book / open notes
- since our book and notes are accessed on a computer, and we're trying to save paper…
- you may login to your CS accounts and view the HtDP/2e textbook in a browser
- you may open DrRacket for the purpose of viewing the lecture notes, labs, and assignments
- but you may not run any programs or use the Interactions pane in DrRacket to evaluate any expressions (you're on your honor)

- Exam is cumulative, but with an emphasis on the material covered since the first midterm
- Lectures 7–12
- HtDP/2e Parts:
- II Arbitrarily Large Data
- IV Intertwined Data

- Topics:
- lists, list abbreviations
- functions that consume lists, functions that consume multiple lists
- binary trees (e.g., rumor mill, pipeline), and functions that consume them
- intertwined data, mutually referential data definitions, mutually recursive functions (e.g. more realistic rumor mill, files and directories), and functions that consume intertwined data

- 5 questions, 15 points each
**Q1**Russian Dolls question based on HtDP/2e Section 9.4- You will be asked to write a function that consumes a Russian Doll (RD).
- Even though this may seem to be something completely different, the Data Definition for a RD is really a thinly-veiled list! Design Recipe.

**Q2**List of Structs Function. I will give you a the data and structure definitions, you will write the functions.- This could be a list of posns, a list of balls, a list of animals of some kind–a list of any kind of struct.
- You might have to design a function that consumes a struct, and a function that consumes a list of those structs.

**Q3**Multiple Lists Function. You will be asked to write a function that consumes two lists. Based on Lecture 9, Multiple Complex Inputs. I'll even promise you it will be of the second variety (`parallel-sum`

was an example of this variety).- The question I ask you to write will be a variation of the question on the sample test.

**Q4**Binary Tree Function. I provide the data definition, you write the function. Design Recipe.- I will even promise you it will be the same definition of a binary tree as on the sample test, but…
- The function I will ask you to write will be different.

**Q5**Function based on intertwined data: This question will be based on the data definitions for Files and Directories, from Lecture 12. I provide the data definition, you write the function(s). Recall: for intertwined data, when you are asked to write a function, you actually write multiple functions, one for each data definition. Design Recipe.- Again, the function(s) I ask you to write will be a variation of the function on the sample test.

### Tuesday

- Midterm 2

### Wednesday

- Recipe Card Check

- Lecture 13: Random functions and Local expressions
- random-symbol-v1.rkt (run in the Stepper—skip slides 14–39)

- Lecture 14: Abstraction, Higher Order Functions

- check-syntax-example.rkt