Quiz 4 Solutions

Wed Apr 5

You have up to 25 minutes. You may use a standard calculator if necessary, but no text book, notes, or computer.

  1. Evaluate the following prefix expression. What result does it produce?

    (* (+ 3 4) (- 6 1))

    ⇒ (* 7 (- 6 1))
    ⇒ (* 7 5)
    ⇒ 35

  2. Evaluate the following postfix expression. What result does it produce?

    4 1 3 + * 2 -

    Evaluate the operators left to right. Each one refers to the previous two things in the list.

    4 1 3 + * 2 -
      \___/
    4  4  * 2 -
    \_____/
    16  2 -
    \_____/
    14

  1. Convert the following infix expression to postfix notation:

    3 * (8 + 2) - (6 + 1)

    You don’t need to produce an explicit tree to convert, but if you do, here’s the correct one:

    The postfix expression is:

    3 8 2 + * 6 1 + -

  1. In our overview of operating systems, we used a picture where the OS sits between the hardware on one end, and the user and applications on the other.

    Name one responsibility of the OS relating to each of these other entities:

    • Hardware devices:

      The OS initializes HW devices, and provides users and apps an interface to them.

    • Applications:

      The OS provides an Application Programming Interface (API), so that applications can run and interact on the OS.

    • Users:

      The OS provides a user interface, whether graphical or a command-interpreter.