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.

1, 0, 5, 1, 10, 3

Question 3: (2 points)

(put 'cm 'centimeters contents)

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

• 2 points for a completely correct solutions
• 1 point for a partially incorrect solution e.g.
• using cdr instead of contents
• no use of contents
• 0 points for an incorrect answer e.g.
• redefining any functions

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

(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

• Recurses completely on Trees AND Forests (see 3 below)
• Removes some of the subtrees (see 1 below)

3/6 traverses the entire tree and makes a tree

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

• recurses on Trees and Forests - perhaps not with the same check
• successfully (correct check) recurses one level down
• traverses the entire tree, but does not make a tree

2/6 Major errors

• Calling a HOF without a procedure as an argument (or a list if it expects one) was the most common one

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)

• double counts with all categories - DAVs are important on trees.
• Can only get one point off for multiple DAVs

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.

• 1 point - tricky in global environment points to procedure with parameters: a and second bubble points to global environment.
• 1 point 3 sets of bubble in the diagram (not necessarily correct)
• 1 point 4 frames (not necessarily connected correctly)
• global with a and tricky
• one with a
• one with b and c
• one with no variables
• 1 point bubbles all correct
• correct parameters
• correct right bubble arrows
• 1 point - 4 frames are chained correctly (can’t get this if they didn’t have the correct variables in each)
• 1 point - a in global points to the correct procedure
• 1 point - a was set to 7 in E1.

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.

• S - 1 point - correct syntax for class, methods
• P - 1 point - proper parent call
• C - 2 points - does not copy code
• (ask self ‘exits) counts as duplicating code
• U - 1 point - uses usual to call parent’s method
• V - 1 point - creating an instance variable to track number of times eaten
• A - 1 point - (ask self ‘possessions)
• E - 1 point - set! of variables

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))))