Spring 2001, CSE 428: Quiz 3.4 - 1 Feb 2001


Please write your Name, Student ID, and Section at the top of the page.

  1. [Pts 2] A location is free (not allocated) in the current environment if (only one answer, please)

    1. it does not have a value
    2. it is not associated to any identifier
    3. it does not occur in the left-hand side of an assignment
    4. it does not occur in the right-hand side of an assignment

  2. [Pts 2] What is the result of the evaluation of an expression in an imperative language (only one answer, please)

    1. a new location
    2. an environment
    3. a value
    4. a parse tree

  3. [Pts 2] What is the result of the evaluation of a command in an imperative language (only one answer, please)

    1. a new program
    2. a new location
    3. a state
    4. an environment

  4. [Pts 2] Consider the following command in the mini-imperative language
       begin
         x
         in x := 5;
            begin y in y := x; x := y; y := 1 + x  end;
            c
       end
    
    What is the value of x at the beginning of the execution of c?
    Note: an equivalent fragment of code in C++ would be:
       int x = 5; { int y; y = x; x = y; y = 1 + x; } c;
    

    Answer: 5

  5. [Pts 2] Consider the following command in the mini-imperative language
       begin
         x
         in x := 1;
            begin x in x := 2; x := x + 1 end;
            c
       end
    
    What is the value of x at the beginning of the execution of c?
    Note: an equivalent fragment of code in C++ would be:
       int x = 1; { int x = 2; x = x + 1; } c;
    

    Answer: 1