This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) focuses on “Postfix to Infix Conversion”.

**1. The prefix expression of the postfix expression AB+CD-* is __________**

A) (A+B)*(C-D)

B) +AB*-CD

C) A+*BCD-**D) *+AB-CD**

Explanation: To convert from postfix to prefix, we first convert it to infix and then to prefix.

postfix : AB+CD-*

infix ⇒ (A+B) * (C-D)

So, prefix ⇒ +AB*-CD,

⇒ *+AB-CD.

Therefore, correct choice is *+AB-CD.

**2. Consider the postfix expression 4 5 6 a b 7 8 a c, where a, b, c are operators. Operator a has higher precedence over operators b and c. Operators b and c are right associative. Then, equivalent infix expression is**

A) 4 a 5 6 b 7 8 a c

B) 4 a 5 c 6 b 7 a 8**C) 4 b 5 a 6 c 7 a 8**

D) 4 a 5 b 6 c 7 a 8

Explanation: Given postfix expression: 4 5 6 a b 7 8 a c

infix ⇒ 4 (5 a 6) b (7 a 8) c

⇒ (4 b (5 a 6)) (7 a 8) c

⇒ (4 b (5 a 6)) c (7 a 8)

So, the required infix expression is 4 b 5 a 6 c 7 a 8.

**3. To convert the postfix expression into the infix expression we use stack and scan the postfix expression from left to right.****A) True**

B) False

Explanation: Stack is used to infix expressions after they have been postfixed. To convert, we must take the following steps: I From left to right, scan the word. (ii) If an operand is detected, it is moved to the top of the stack. (iii) If the operator is detected, the two operands are popped, and the combined infix expression is generated and placed onto the stack.

**4. Which of the following is valid reverse polish expression?**

A) a op b

B) op a b**C) a b op**

D) both op a b and a b op

Explanation: The reverse polish expression is another name for the postfix expression. The operators appear after the operands in postfix expressions. As a consequence, the proper expression is a b op, and a b op is also correct.

**5. The result of the postfix expression 5 3 * 9 + 6 / 8 4 / + is _____________**

A) 8**B) 6**

C) 10

D) 9

Explanation: Given postfix expression: 5 3 * 9 + 6 / 8 4 / +

Result = 5 3 * 9 + 6 / 8 4 / +

= (5 * 3) 9 + 6 / (8 / 4) +

= ((5 * 3) + 9) / 6 + ( 8 / 4) = ( 24 / 6) + 2 = 4 + 2 = 6.

**6. Which of the following data structure is used to convert postfix expression to infix expression?****A) Stack**

B) Queue

C) Linked List

D) Heap

Explanation: Stack is needed to convert a postfix expression to an infix expression. To keep the intermediate infix expressions in tact, we’ll need stack. The operands are stored in a stack.

**7. The postfix expression abc+de/*- is equivalent to which of the following infix expression?**

A) abc+-de*/

B) (a+b)-d/e*c**C) a-(b+c)*(d/e)**

D) abc+*-(d/e)

Explanation: Given postfix expression : abc+de/*-

infix ⇒ a(b+c)(d/e)*-

⇒ a(b+c)*(d/e)-

⇒ a-(b+c)*(d/e)

Hence, correct choice is a-(b+c)*(d/e).

**8. The equivalent infix expression and value for the postfix form 1 2 + 3 * 4 5 * – will be ___________**

A) 1 + 2 * 3 – 4 * 5 and -13

B) (2 + 1) * (3 – 4) * 5 and 13

C) 1 + 2 * (3 – 4) * 5 and -11**D) (1 + 2) * 3 – (4 * 5) and -11**

Explanation: Given postfix expression : 1 2 + 3 * 4 5 * –

⇒ (1 + 2) 3 * 4 5 * –

⇒ ((1 + 2) * 3) 4 5 * –

⇒ ((1 + 2) * 3) (4 * 5) –

⇒ ((1 + 2) * 3) – (4 * 5)

So, the equivalent infix expression is (1 + 2) * 3 – (4 * 5) and it’s value is -11.

**9. What is the value of the postfix expression 2 3 + 4 5 6 – – ***

A) 19

B) 21

C) -4**D) 25**

Explanation: Given postfix expression : 2 3 + 4 5 6 – – *

infix ⇒ (2 + 3)4 (5 – 6) – *

⇒ (2 + 3)*4 – (5 – 6)

Hence, value = (2 + 3) * (4 – (5 – 6)) = 5 *(4 – (-1)) = 5*5 = 25.

The representation of the form an op b in infix form. If an operator is sandwiched between two operands. The expression of the type a b op with a postfix. When each pair of operands is accompanied by an operator. A postfix expression is known as reverse polish Notation, while a prefix expression is known as Polish Notation or Warsaw Notation. The corresponding postfix expression for the infix expression is abc/d-, as determined by the infix to postfix conversion algorithm.