AUGUSTANA UNIVERSITY COLLEGE

CSC 370 -- PROGRAMMING LANGUAGES

Mid-Term Exam

1999 October 20

NAME:


Time allowed: 50 minutes. Closed book exam -- no references allowed.

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.


[10] 1. TRUE or FALSE -- Indicate whether each of the following statements is true or false by writing a T or F, respectively, in the blank preceding each statement.

    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

  1. A group of procedures that share a state.
  2. A type of programming language which facilitates computation by means of state changes.
  3. The set of rules for generating valid statements in a programming language.
  4. Varying independently of other features.
  5. Identifying which tokens represent values, identifiers, operators, etc.; lexical analysis.
  6. Recognizing valid statements of a source language by grouping tokens into syntactic structures; syntactic analysis.
  7. Giving more than one name to a storage location.
  8. A pool of memory in which space can be dynamically allocated and deallocated.
  9. The assignment of a variable to its attributes (name, address, type, and value).
  10. The period of time that an object is bound to an address.
  11. A contiguous section of code in which local variables can be declared.
  12. The set of statements and expressions for which a variable is bound.

[2] 3. A two-dimensional array is declared in FORTRAN by

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