arrow
arrow
arrow
Which of the following infix expressions is obtained on converting the postfix expression A B - C + D E F - + $?
Question

Which of the following infix expressions is obtained on converting the postfix expression A B - C + D E F - + $?

A.

A - B + C + D $ E – F

B.

A - B + C $ D + E – F

C.

A - B $ C + D + E – F

D.

A + B - C $ D + E – F

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:

  1. Push A, B → Stack: A, B
  2. - → Pop B, A → Push (A - B)
    → Stack: (A - B)
  3. Push C
    → Stack: (A - B), C
  4. + → Pop C, (A - B) → Push ((A - B) + C)
    → Stack: ((A - B) + C)
  5. Push D, E, F
    → Stack: ((A - B) + C), D, E, F
  6. - → Pop F, E → Push (E - F)
    → Stack: ((A - B) + C), D, (E - F)
  7. + → Pop (E - F), D → Push (D + (E - F))
    → Stack: ((A - B) + C), (D + (E - F))
  8. $ → 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:

  1. Postfix to infix conversion uses a stack and binary operator evaluation.
  2. The operator $ (typically custom-defined) is treated like any binary operator here.
  3. 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.

Free Tests

Free
Must Attempt

MPTET Varg 3 PRT Mock 01

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
Free
Must Attempt

MPTET Varg 3 PRT CDP Subject Test 01

languageIcon English
  • pdpQsnIcon20 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon20 Mins
languageIcon English
Free
Must Attempt

UPTET Paper 2 Social Science : PYP Held on 23rd Jan 2022 (Shift 2)

languageIcon English
  • pdpQsnIcon150 Questions
  • pdpsheetsIcon150 Marks
  • timerIcon150 Mins
languageIcon English
test-prime-package

Access ‘UPSSSC’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
383k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow