# Evaluation of an Infix Expression (Not Parenthesized) – Data Structure Questions and Answers

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

**1. Evaluation of infix expression is done based on precedence of operators.****A) True**

B) False

Explanation: Operators with higher precedence are evaluated first, followed by operators with lower precedence during infix expression evaluation.

**2. Of the following choices, which operator has the lowest precedence?**

A) ^

B) +

C)/**D) #**

Explanation: # is the operator with the lowest precedence, followed by +, /, and finally /.

**3. The system throws an error if parentheses are encountered in an infix expression evaluation algorithm.**

A) True**B) False**

Explanation: For infix expressions with parentheses, the algorithm holds true. There are no errors thrown by the machine.

**4. 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

Explanation: * and / have higher priority. Hence, they are evaluated first. Then, + is evaluated. Hence, 2+2=4.

**5. 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

Explanation: 4*2 and 5/5 are evaluated first and then, 8+3-1 is evaluated and the result is obtained as 10.

**6. 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**

Explanation: ^ has the highest precedence. Hence, 2^2 is evaluated and then 4+2 gives 6.

**7. 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

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.

**8. From the given expression tree, identify the infix expression, evaluate it and choose the correct result.**

A) 5

B) 10**C) 12**

D) 16

Explanation: The result of the infix expression is calculated as 12 using the given expression tree.

**9. How many stacks are required for applying evaluation of infix expression algorithm?**

A) one**B) two**

C) three

D) four

Explanation: For the evaluation of infix expressions, two stacks are required: one for operands and one for operators.

**10. How many passes does the evaluation of infix expression algorithm makes through the input?****A) One**

B) Two

C) Three

D) Four

Explanation: Infix expression algorithm evaluation is linear, requiring only one pass through the data.

**11. 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: Since the operators are sandwiched between the operands, a/b+(c-d) is an infix phrase.

**12. 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

Explanation: The operator is moved on to the stack operator if its precedence is higher than the stack operator.

**13. 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: The precedence of operators determines that * is evaluated first. Both + and – have the same priority. As a consequence, 1+6-2=5.

Humans can understand and solve infix expressions. When solving mathematical expressions, we can easily discern the order of operators and use the parenthesis to solve that part first. Since the machine has difficulty distinguishing between operators and parenthesis, postfix conversion is required. 1 Remove the operator from the operator stack when it is still not empty. 2 Get two operands by popping the value stack twice. 3 In the correct order, apply the operator to the operands. 4 Place the outcome on the value stack.