Teaching
2500 F '11
 
Assignments
The Hand In
Set 1
Set 2
Set 3
Set 3h
Set 4
Set 4h
Set 5
Set 5h
Set 6
Set 7
Set 6h
Set 8
Set 7h
Set 9
Set 8h
Set 10
Set 9h
Set 11
Set 10h
Set 12

Problem Set 9

Due date: 11/7 @ 11:59pm

Programming Language: Intermediate Student Language with lambda


This problem set has two main goals: first, to practice the use of existing abstractions; second, to learn how to edit programs that you have already written, an essential skill for any programmer.


HtDP Problems:

19.1.6, 19.2.4, 20.2.4, 21.1.1, 21.1.3

Problem A1:

Edit your Tetris project once again. Be sure to fix any and all problems that your graders have (or would have) discovered.

Next, you are to use local and "loops" (abstractions such as map, foldr, filter, etc.) wherever your functions may benefit from them, especially for the lists of objects in your project.

You should notice that the length of your program decreases considerably.

Problem A2:

Part 1:

Develop data definitions for binary trees of Symbols, and binary trees of Numbers. The numbers and symbols should occur at the leaf positions only.

Create two instances of each, and abstract over the data definitions.

Design the function height, which consumes any binary tree and computes its height. That is, the maximum number of nodes from the root of the given tree to a leaf. Here's some tests to further explain:

      (check-expect (height 5) 0)
      (check-expect (height (make-node 'yes (make-node 'no 'maybe))) 2)
        

Part 2:

A leafy binary tree is a binary tree with the symbol 'leaf at its leafs.

Design a function that consumes a natural number n and creates (a list of) all leafy binary trees of height n.

Hint: Design a function that consumes a natural number n and creates (a list of) all leafy binary trees of height equal or less than n.

Warning: this is not about abstraction; it's just a reminder that more interesting (and complex) programs are around the corner.


last updated on Tue Nov 29 19:02:43 EST 2011generated with Racket