This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses 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

View Answer

Explanation: 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

View Answer

Explanation: 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

View Answer

Explanation: 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

View Answer

Explanation: 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

View Answer

Explanation: 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

View Answer

Explanation: 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) #

View Answer

Explanation: 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

View Answer

Explanation: 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

View Answer

Explanation: * 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

View Answer

Explanation: 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

View Answer

Explanation: ^ 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

View Answer

Explanation: ^ 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.

a) 5

b) 10

c) 12

d) 16

View Answer

Explanation: From the given expression tree, the result of the infix expression is evaluated to be 12.

**Sanfoundry Global Education & Learning Series – Data Structure.**

To practice all areas of Data Structure, __here is complete set of 1000+ Multiple Choice Questions and Answers__.

**Next Steps:**

- Get Free Certificate of Merit in Data Structure I
- Participate in Data Structure I Certification Contest
- Become a Top Ranker in Data Structure I
- Take Data Structure I Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

**Related Posts:**

- Practice Design & Analysis of Algorithms MCQ
- Buy Data Structure Books
- Apply for Data Structure Internship
- Buy Programming Books
- Apply for Computer Science Internship