How many stacks are required for applying evaluation of infix
expression algorithm?
a) one
b) two
c) three
d) four
Explanation: Two stacks are required for evaluation of infix expression – one for operands and one for operators.
How many passes does the evaluation of infix expression algorithm makes through the input?
a) One
b) Two
c) Three
d) Four
Explanation: Evaluation of infix expression algorithm is linear and makes only one pass through the input.
Identify the infix expression from the list of options given below.
a) a/b+(c-d)
b) abc*+d+ab+cd+*ce-f-
c) ab-c-
d) +ab
Explanation: a/b+(c-d) is an infix expression since the operators are placed in between the operands.
Which of the following statement is incorrect with respect to evaluation of infix expression algorithm?
a) Operand is pushed on to the stack
b) If the precedence of operator is higher, pop two operands and evaluate
c) If the precedence of operator is lower, pop two operands and evaluate
d) The result is pushed on to the operand stack
Evaluate the following statement using infix evaluation algorithm
and choose the correct answer. 1+2*3-2
a) 3
b) 6
c) 5
d) 4
Explanation: According to precedence of operators, * is evaluated first. + and – have equal priorities. Hence, 1+6-2= 5.
Of the following choices, which operator has the lowest precedence?
a) ^
b) +
c) /
d) #
Explanation: The operator with the lowest precedence is #, preceded by +, / and then ^.