NAME:
Write all answers in the space provided. You may use the back of the last page for scratch work or to continue answers. Label all continuations clearly.
There are 11 questions worth a total of 64 points. The point value of each question is indicated in square brackets in the left-hand margin. Schedule your time accordingly.
LISP, C++, and Java use garbage collection to manage the run-time deallocation of memory.
Pascal uses lazy evaluation of Boolean or logical expressions.
Call by name is the default parameter-passing mode in FORTRAN.
In Prolog, unifying an uninstantiated variable with an instantiated variable will cause the former one to become instantiated to the same value as the latter one.
Prolog uses a breadth-first search strategy.
Algol uses dynamic scoping for procedure calls.
Ada uses dynamic scoping for exception handling.
Ada uses fully bracketed control structures.
A reserved word may be used for other purposes by overloading.
Variant records are a loophole in the typing system of both Pascal and Ada.
[12] 2. MATCHING -- Match each term in the left column with the phrase in the right column which best defines or describes it.
|
aliasing binding block heap imperative lifetime object orthogonal parsing scanning scope syntax |
|
INTEGER A(4,5)
Element A(3,2) is in the word at address 1103. Assuming an INTEGER is stored in one word, at which address is element A(2,4) stored? (Remember: FORTRAN uses 1-based, column-major indexing of arrays.)
[4] 4. The following syntax diagram specifies the syntax of the Ada if statement, using rectangles to indicate nonterminal symbols and ovals to indicate terminals. Convert this syntax specification to EBNF, using < > to enclose nonterminals and using ( ) { } [ ] and | as specified in the textbook. All other symbols will be assumed to be terminal symbols.
[6] 5. Use boxes, arrows, and atom names to draw a representation of the data structure which would result from executing the following LISP code.
(set 'L '(backus naur (von neumann) knuth))
(set 'M (cons 'john (caddr L)))
[2] 6. What is the result of evaluating the following LISP expression?
((lambda (x y) (+ x y y 3)) 2 5)
[3] 7. Given the following LISP code
( defun unknown ( L )
( cond
(( null L ) nil )
( t ( cons ( list ( cadar L ) ( caar L ))
( unknown ( cdr L ))))
)
)
what is the result of evaluating the following expression?
(unknown '((1 a) (2 b) (3 c) (4 d) (5 e)))
[3] 8. The LISP function mapcar applies its first argument (a function) to each element of its second argument (a list), returning a list of the results. What is the result of evaluating the following function call?
(mapcar (lambda (x) (* x 2)) '(1 2 3))
[4] 9. Name two automatic storage management techniques and indicate one major disadvantage of each technique.
[There were two additional questions, but we have not yet studied the topic they examine.]
Copyright © 1999 Jonathan Mohr