Infix / Postfix Expression
1. The following postfix expression with single-digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * -
Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
Answer: 6, 1
2. Assume that the operators +, -, × are left-associative and ^ is right-associative. The order of precedence (from highest to lowest) is ^, x, +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is
Answer: abc × + def ^ ^ -
3. The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is
Answer: 142
4. Convert the following infix expression into its equivalent post fix expression (A + B^ D) / (E – F) + G
Answer: ABD^ + EF – / G+
5. The best data structure to check whether an arithmetic expression has balanced parenthesis is a __________
Answer: Stack