Midterm 2 Rubric Draft (Subject to Change)

Question 1A: (3 points)

1 point for 1st blank (all or nothing)

1 point for 2nd blank (all or nothing)

1 point for correct diagram (all or nothing)

-1 point for quoting stuff that shouldn’t be quoted

Question 1B: (3 points)

1 point for j and k being equal

1 point for them being correct

1 point for the correct diagram

-1 point for quoting stuff that shouldn’t be quoted

Question 2:  (3 points)

1 point for each expression - all or nothing. Must get both eval-1 and apply-1 #’s correct.

Answers:

1, 0, 5, 1, 10, 3

Question 3: (2 points)

(put 'cm 'centimeters contents)

(put 'in 'centimeters (lambda (obj) (* 2.54 (contents obj))))

Question 4: (4 points)

1 point for crossing off 3 of the lambda()’s.

1 point for crossing off the 2nd let, but not the first

1 point for the top let being AFTER a lambda() - can’t earn this point if they crossed off the wrong let.

1 point for filling in the blank correctly.

(define make-team

  (lambda ()

    (let ((player-names '()))

      (lambda (message player-name)

        (cond

         ((equal? message 'add)

          (set! player-names (sentence player-name player-names)))

         ((equal? message 'contains?)

          (member? player-name player-names)))))))

Question 5: (3 points)

1 point for calling  set-car! on lol

1 point for setting the car to the correct value (cannot get this point if set-car! was not given the correct argument)

1 point for the correct recursive call (solution cannot depend on recursive call having a return value)

-1 point if list structure is incorrectly altered in some way

0 points if created new pairs (i.e. called cons, list, append, or map)

(set-car! lol (list-ref (car lol) n))

        (diagonalize-n! (cdr lol) (+ n 1))

Question 6:

6/6 correct

5/6 one or two small mistakes

4/6 has the idea

3/6 traverses the entire tree and makes a tree

2/6 has an idea: does one of the following

2/6 Major errors

Three main areas:

1) A correct check

2) Modulating the making of trees (correctly makes trees)

3) Traversing the entire tree

Common mistakes:

-1 for returning the (datum Tree)

-1 for DAV (across the whole problem)

A common error we found was that people would return ‘() or not return anything (which results in the word ‘okay) instead of removing a subtree. These solutions received 4 points.

(define (bigger-kids Tree)

  (make-tree (datum Tree)

             (bigger-kids-forest (children Tree) (datum Tree))))

(define (bigger-kids-forest forest parent-datum)

  (filter (lambda (Tree) (> (datum Tree) parent-datum))

          (map bigger-kids forest)))

(define t (make-tree 6

                     (list

                      (make-tree 5 (list (make-tree 7 '()) (make-tree 1 '())))

                      (make-tree 7 (list (make-tree 8 '()) (make-tree 4 '())))

                      (make-tree 9 '()))))

Question 7:  7 points

(environment diagram)

Solution:

answers to blanks in corresponding order: 5, 7, proc

You should use envdraw to check the solution more accurately, but there should have been 4 frames and three procedures, the frames extended each other linearly, meaning that e3 extends e2, which extends e1, which extends the global.  The important variable were that in the end, a in the global points to the procedure of no arguments.  a in e1 should have started as 5, then been changed to 7 after a set!.  The rest you should check with envdraw.

Rubric for Grading:

Important Notes:

We did not care about the blanks so long as the diagram was correct, the idea here was that we were more interested in testing your ability to draw env diagrams vs your ability to trace through code.  The blanks were more to help you think about what should be happening.  We also did not care about the exact semantics of drawing bubbles for procedures, for example we did not care if the left bubble pointed to the env, instead of the right bubble.

Lastly:  We did actually deduct one point from the final score of the problem for things that heavily violated the main semantic ideas behind env diagrams.  Examples of such things were having frames extending multiple frames, or having frames point to procedures instead of other frames.

Question 8: 8 points

Codes indicate that a particular element was included in your solution.

Logic errors deducted one point, up to -2.

(define-class (wimp name place capacity)

  (parent (person name place))

  (instance-vars (fed 0))

  (method (go direction)

          (if (< capacity (length (ask self 'possessions)))

              'too-heavy

              (usual 'go direction)))

  (method (eat)

          (if (= 1 fed)

              (begin (set! capacity (+ 1 capacity))

                     (set! fed 0))

              (set! fed 1))))