Computer Science 3675
Fall 2014
Practice Questions for Quiz 1

  1. Which of the following are true, and which are false?

    1. All compilers translate to machine language.

      Answer

    2. All programming language implementations are compilers.

      Answer

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

    Answer

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

    Answer

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

    Answer

  5. What is the head of list [3,5,4,8]?

    Answer

  6. What is the tail of list [3,5,4,8]?

    Answer

  7. What is the head of list [4,2]?

    Answer

  8. What is the tail of list [4,2]?

    Answer

  9. Given the definition

        f([])   = []
        f(h::t) = (h*h)::f(t)  when h > 10
        f(h::t) = f(t)         when h <= 10
    
    show an evaluation of expression f([4,12,15,6,11]) by substitution. Show the entire expression at each step. Assume that arithmetic is done as soon as possible.

    Answer

  10. Write an equational definition of a function prefix so that prefix(x,y) is true just when list x is a prefix of list y. For example, prefix([1,2], [1,2,4,6]) is true, but prefix([1,2], [1,5,2,6]) is false. It is not required that x be a proper prefix of y. So prefix([2,3], [2,3]) is true. The empty list is a prefix of every list.

    Answer

  11. Show an inside-out evaluation of prefix([1,2], [1,2,3,4]) using your definition of prefix from the preceding question. Show the entire expression at each step.

    Answer