250+ TOP MCQs on Evaluation of an Infix Expression (Not Parenthesized) and Answers

Data Structures & Algorithms Multiple Choice Questions on “Evaluation of an Infix Expression (Not Parenthesized)”.

1. How many stacks are required for applying evaluation of infix expression algorithm?
a) one
b) two
c) three
d) four
Answer: b
Clarification: Two stacks are required for evaluation of infix expression – one for operands and one for operators.

2. How many passes does the evaluation of infix expression algorithm makes through the input?
a) One
b) Two
c) Three
d) Four
Answer: a
Clarification: Evaluation of infix expression algorithm is linear and makes only one pass through the input.

3. 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
Answer: a
Clarification: a/b+(c-d) is an infix expression since the operators are placed in between the operands.

4. 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
Answer: b
Clarification: If the precedence of the operator is higher than the stack operator, then it is pushed on to the stack operator.

5. 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
Answer: c
Clarification: According to precedence of operators, * is evaluated first. + and – have equal priorities. Hence, 1+6-2= 5.

6. Evaluation of infix expression is done based on precedence of operators.
a) True
b) False
Answer: a
Clarification: During evaluation of infix expression, the operators with higher precedence are evaluated first, followed by operators with lower precedence.

7. Of the following choices, which operator has the lowest precedence?
a) ^
b) +
c) /
d) #
Answer: d
Clarification: The operator with the lowest precedence is #, preceded by +, / and then ^.

8. The system throws an error if parentheses are encountered in an infix expression evaluation algorithm.
a) True
b) False
Answer: b
Clarification: The algorithm holds good for infix expression with parentheses. The system does not throw error.

9. Evaluate the following and choose the correct answer.
a/b+c*d where a=4, b=2, c=2, d=1.
a) 1
b) 4
c) 5
d) 2
Answer: b
Clarification: * and / have higher priority. Hence, they are evaluated first. Then, + is evaluated. Hence, 2+2=4.

10. Evaluate the following statement using infix evaluation algorithm and choose the correct answer. 4*2+3-5/5
a) 10
b) 11
c) 16
d) 12
Answer: a
Clarification: 4*2 and 5/5 are evaluated first and then, 8+3-1 is evaluated and the result is obtained as 10.

11. Using the evaluation of infix expression, evaluate a^b+c and choose the correct answer. (a=2, b=2, c=2)
a) 12
b) 8
c) 10
d) 6
Answer: d
Clarification: ^ has the highest precedence. Hence, 2^2 is evaluated and then 4+2 gives 6.

12. Evaluate the following infix expression using algorithm and choose the correct answer. a+b*c-d/e^f where a=1, b=2, c=3, d=4, e=2, f=2.
a) 6
b) 8
c) 9
d) 7
Answer: a
Clarification: ^ has the highest order of precedence. Hence, 2^2 is evaluated first, and then, 2*3 and 4/4 are evaluated. Therefore, 1+6-1=6.

13. From the given expression tree, identify the infix expression, evaluate it and choose the correct result.
data-structures-questions-answers-evaluation-infix-expression-not-parenthesized-q13
a) 5
b) 10
c) 12
d) 16
Answer: c
Clarification: From the given expression tree, the result of the infix expression is evaluated to be 12.

Leave a Reply

Your email address will not be published. Required fields are marked *