Wed Nov 15
You have up to 25 minutes. You may use a standard calculator if necessary, but no text book, notes, or computer.
Evaluate the following prefix expression. What result does it produce?
(- (* 3 (+ 1 7)) (+ 9 4))
⇒ (- (* 3 (+ 1 7)) (+ 9 4))
⇒ (- (* 3 8) (+ 9 4))
⇒ (- 24 (+ 9 4))
⇒ (- 24 13)
⇒ 11
Evaluate the following postfix expression. What result does it produce?
2 5 2 + 4 * 1 - *
Evaluate the operators left to right. Each one refers to the previous two things in the list.
2 5 2 + 4 * 1 - *
2 7 4 * 1 - *
2 28 1 - *
2 27 *
54
(* (* 2 5) (+ 7 2))
2 * 5 * (7 + 2)
Convert the following infix expression to postfix notation:
3 * (2 + 8) - (6 + 1)
The postfix expression is:
3 2 8 + * 6 1 + -