Correct option is B
Step-by-Step Conversion of Postfix to Infix:
We’ll use a stack to convert postfix to infix.
Given Postfix Expression:
A B - C + D E F - + $
Let’s process it left to right:
- Push A, B → Stack: A, B
- - → Pop B, A → Push (A - B)
→ Stack: (A - B) - Push C
→ Stack: (A - B), C - + → Pop C, (A - B) → Push ((A - B) + C)
→ Stack: ((A - B) + C) - Push D, E, F
→ Stack: ((A - B) + C), D, E, F - - → Pop F, E → Push (E - F)
→ Stack: ((A - B) + C), D, (E - F) - + → Pop (E - F), D → Push (D + (E - F))
→ Stack: ((A - B) + C), (D + (E - F)) - $ → Pop (D + (E - F)), ((A - B) + C) → Push (((A - B) + C) $ (D + (E - F)))
Now expand and format:
Final Infix Expression: A - B + C $ D + E – F
This matches option (b).
Important Key Points:
- Postfix to infix conversion uses a stack and binary operator evaluation.
- The operator $ (typically custom-defined) is treated like any binary operator here.
- Proper parenthesis are used during evaluation but omitted in final flattened form when no precedence/associativity is explicitly defined.
Knowledge Booster:
- Option A: Misplaces $ between C and D too early, disrupting actual evaluation order.
- Option C: Misplaces $ between B and C, which never occurs in postfix parsing.
- Option D: Starts with A + B, which never happens as the first operator in actual stack processing.