5. Tree and list notation.
I suggest that you go over the related question on the quiz. Make up some examples of smallish binary trees, and find all of the Scheme notations for them.
- If
expr1 is an S-expression with n different Scheme notations, and we derive expr2 from expr1 by replacing all ()s with the symbol a, how many different Scheme notations does expr2 have?
- Are the notation and procedures of Scheme biased toward supporting long right branches in binary trees, or long left branches? Does this bias lead to more or fewer notations for the favored tree shapes? This question is not similar to the exam questions, but it could stimulate some good thinking.
- Suppose that the list of
a, b, and c were represented by (a . (b . c)) instead of by (a . (b . (c . ()))). How would this affect the number of different notations for a list? (An important question for programming language design, but not relevant to this particular exam problem, is the effect of such a notation on the structure of procedure definitions).
|