Computer Science 3675
Fall 2002
Practice questions for quiz 1

  1. Write a clearly legible T to the left of each of the following that is true, and a clearly legible F to the left of each that is false.

    1. All compilers translate to machine language.
    2. All programming language implementations are compilers.
    3. A garbage collector based on reference counts cannot collect cyclic structures.
    4. A simple value is a value that has no visible internal structure.
    5. Characters are typically considered complex values.
    6. A data structure that changes over time is not considered to be a value.
    7. Operational semantics describe things in a computer program by attaching values from a standard model to them.
    8. A token can only have one associated lexeme.
    9. A variable name is typically a single lexeme in a program.
    10. Backus-Naur Form is a notation for giving precise definitions of syntax.

  2. An implementation of a programming language is not normally considered to be an adequate definition of the language. Why not? What would be the consequences of using an implementation as a definition?

  3. What is an important advantage of the linked representation of sequences over the sequential representation?

  4. What is an important advantage of the sequential representation of sequences over the linked representation?

  5. Show that the following BNF grammar is ambiguous. The start symbol is <S>.

        <S> ::= <S> a
             |  a <S>
             |  a
      

  6. Show a parse tree for string aacacab according to the following grammar, where the start symbol is <S>.

        <S> ::= <F> a <S>
             |  b
        <F> ::= a <F>
             |  c
      

  7. Write a BNF grammar for sequences of left and right parentheses that are balanced. A sequence of parentheses is balanced if parentheses match and are well nested. For example, (()(())) is balanced, but )( and ())()( are not balanced.

  8. What is a solution to pattern match equation [x,y+1] = [7,99]?