This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 61A, Spring 1999 Midterm #2 Professor Brian Harvey Question 1 (4 points): What will Scheme print in response to the following expressions? If an expression produces an error message, you may just say "error"; you don't have to provide the exact text of the message. If the value of an expression is a procedure, just say "procedure"; you don't have to show the form in which Scheme prints procedures. Also, draw a box and pointer diagram of the value produced by each expression. (cons '(a b) '(( c d))) (cdadr '((1 2 3) (4 5 6) (7 8 9))) (cons (list '(a) '(b)) (list 'c 'd)) (cons '(a b) 'c) Question 2 (5 points): A threetree is a treelike structure in which each node contains two values, called the leftdatum and the rightdatum , and up to three children, called the leftbranch , the middlebranch , and the rightbranch . (Any of these can be an empty list instead of a threetree.) (a) Write the constructor (make3 lftdat rtdat lftbr midbr rtbr) and the appropriate selectors so that a...
View
Full
Document
This note was uploaded on 11/23/2010 for the course CS 61A taught by Professor Harvey during the Fall '08 term at University of California, Berkeley.
 Fall '08
 Harvey
 Computer Programming

Click to edit the document details