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

Problem Set 8h

Due date: 11/08 @ 11:59pm

Programming Language: Intermediate Student Language with lambda


Honors-section homework

Problem A1

Develop the hangman game. The hangman game has a secret word that the player tries to guess. The player guesses letters by pressing keys on the keyboard. If the guessed letter is correct, it is revealed on the screen. For example, suppose the secret word is "guess" and the player presses the "s" key. The game should reveal something like:

The player loses if seven incorrect guesses are made. The player wins if the secret can be revealed with less than seven incorrect guesses. The player should not be penalized for repeatedly guessing the same incorrect letter.

The game should also reveal a "hangman" that shows the players progress toward losing. Each wrong guess adds another body part to the hangman. For example, if the user had guessed "t", "u", "s", "q", "r", the game should look something like:

The hangman is complete when enough wrong guesses have been made:

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 Sun Dec 2 14:52:34 EST 2012generated with Racket